> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Responses

> Use CometAPI POST /v1/responses to generate advanced model outputs with multimodal input, stateful chat, built-in tools, and function calling.

The Responses API extends [Chat Completions](/api/text/chat) with stateful conversations, built-in tools, multimodal file inputs, and reasoning control. It is the recommended endpoint for OpenAI o-series reasoning models, GPT-5 series, and Codex models.

<Warning>
  Different model providers support different request parameters and return varying response fields. Not all parameters listed in the playground above work with every model on CometAPI.
</Warning>

***

## Use stateful conversations

Chain responses together using `previous_response_id` instead of managing message history yourself:

```python theme={null}
from openai import OpenAI

client = OpenAI(
    base_url="https://api.cometapi.com/v1",
    api_key="<COMETAPI_KEY>",
)

# First turn
response = client.responses.create(
    model="gpt-5.4",
    input="What is quantum computing?",
)

# Second turn — previous context is included automatically
follow_up = client.responses.create(
    model="gpt-5.4",
    input="Can you explain that more simply?",
    previous_response_id=response.id,
)

print(follow_up.output_text)
```

***

## Use built-in tools

The Responses API includes platform-provided tools that require no configuration:

| Tool                 | Purpose                                  |
| -------------------- | ---------------------------------------- |
| `web_search_preview` | Search the web for real-time information |
| `file_search`        | Search through uploaded files            |
| `code_interpreter`   | Execute Python code in a sandbox         |

To enable a built-in tool, add it to the `tools` array:

```python theme={null}
response = client.responses.create(
    model="gpt-5.4",
    input="Find the current price of Bitcoin",
    tools=[{"type": "web_search_preview"}],
)

print(response.output_text)
```

***

## Call custom functions

Define functions the model can invoke with structured arguments:

```python theme={null}
response = client.responses.create(
    model="gpt-5.4",
    input="What's the weather in Tokyo?",
    tools=[{
        "type": "function",
        "name": "get_weather",
        "description": "Get current weather for a location",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {"type": "string"}
            },
            "required": ["location"]
        }
    }],
)
```

When the model calls a function, the response `output` array contains a `function_call` item with the function name and parsed arguments. Execute the function and send the result back in a follow-up request.

***

## Request structured output

To force JSON output matching a specific schema, use the `text.format` parameter:

```python theme={null}
response = client.responses.create(
    model="gpt-5.4",
    input="List 3 programming languages with their main use cases",
    text={
        "format": {
            "type": "json_schema",
            "name": "languages",
            "strict": True,
            "schema": {
                "type": "object",
                "properties": {
                    "languages": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "name": {"type": "string"},
                                "use_case": {"type": "string"}
                            },
                            "required": ["name", "use_case"],
                            "additionalProperties": False
                        }
                    }
                },
                "required": ["languages"],
                "additionalProperties": False
            }
        }
    },
)
```

***

## Configure reasoning

For o-series and GPT-5 models, control reasoning depth with `reasoning.effort`:

```python theme={null}
response = client.responses.create(
    model="o3",
    input="Solve this step by step: if f(x) = x^3 - 6x^2 + 11x - 6, find all roots.",
    reasoning={"effort": "high"},  # "low", "medium", or "high"
)

print(response.output_text)
```

<Tip>
  Higher reasoning effort produces more thorough answers but uses more tokens. Use `"low"` for simple queries and `"high"` for complex multi-step problems.
</Tip>

***

## Stream responses

To receive incremental output, set `stream` to `true`. The API sends server-sent events (SSE) in this order:

1. `response.created` — Response object initialized
2. `response.in_progress` — Generation started
3. `response.output_item.added` — New output item (message or tool call)
4. `response.content_part.added` — Content part started
5. `response.output_text.delta` — Text chunk (contains `delta` field)
6. `response.output_text.done` — Text generation complete for this content part
7. `response.content_part.done` — Content part finished
8. `response.output_item.done` — Output item finished
9. `response.completed` — Full response with `usage` data

Stream a response with the Python SDK:

```python theme={null}
stream = client.responses.create(
    model="gpt-5.4",
    input="Write a haiku about coding",
    stream=True,
)

for event in stream:
    if event.type == "response.output_text.delta":
        print(event.delta, end="")
```

***

<Tip>
  For in-depth guides on each capability, see the OpenAI documentation:
  [Text](https://developers.openai.com/docs/guides/text) · [Images](https://developers.openai.com/docs/guides/images) · [PDF files](https://developers.openai.com/docs/guides/pdf-files) · [Structured Outputs](https://developers.openai.com/docs/guides/structured-outputs) · [Function Calling](https://developers.openai.com/docs/guides/function-calling) · [Conversation State](https://developers.openai.com/docs/guides/conversation-state) · [Built-in Tools](https://developers.openai.com/docs/guides/tools) · [Reasoning](https://developers.openai.com/docs/guides/reasoning)
</Tip>


## OpenAPI

````yaml /api/openapi/text/post-responses.openapi.json POST /v1/responses
openapi: 3.1.0
info:
  title: Responses API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /v1/responses:
    post:
      summary: Create Response
      operationId: createResponse
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
              properties:
                model:
                  type: string
                  description: >-
                    Model ID to use for this request. See the [Models
                    page](/overview/models) for current options.
                  example: gpt-5.4
                input:
                  oneOf:
                    - type: string
                      description: A plain text string as input.
                    - type: array
                      description: >-
                        An array of input items with roles and multimodal
                        content.
                      items:
                        type: object
                  description: >-
                    Text, image, or file inputs to the model, used to generate a
                    response. Can be a simple string for text-only input, or an
                    array of input items for multimodal content (images, files)
                    and multi-turn conversations.
                instructions:
                  type: string
                  description: >-
                    A system (or developer) message inserted into the model's
                    context. When used with `previous_response_id`, instructions
                    from the previous response are not carried over — this makes
                    it easy to swap system messages between turns.
                background:
                  type: boolean
                  description: >-
                    Whether to run the model response in the background.
                    Background responses do not return output directly — you
                    retrieve the result later via the response ID.
                  default: false
                context_management:
                  type: array
                  description: >-
                    Context management configuration for this request. Controls
                    how the model manages context when the conversation exceeds
                    the context window.
                  items:
                    type: object
                    properties:
                      type:
                        type: string
                        description: The type of context management.
                      compact_threshold:
                        type: number
                        description: >-
                          The threshold at which context compaction is
                          triggered.
                conversation:
                  type:
                    - string
                    - object
                    - 'null'
                  description: >-
                    The conversation this response belongs to. Items from the
                    conversation are prepended to `input` for context. Input and
                    output items are automatically added to the conversation
                    after the response completes. Cannot be used with
                    `previous_response_id`.
                  default: null
                include:
                  type: array
                  description: >-
                    Additional output data to include in the response. Use this
                    to request extra information that is not included by
                    default.
                  items:
                    type: string
                    enum:
                      - web_search_call.action.sources
                      - code_interpreter_call.outputs
                      - computer_call_output.output.image_url
                      - file_search_call.results
                      - message.input_image.image_url
                      - message.output_text.logprobs
                      - reasoning.encrypted_content
                max_output_tokens:
                  type: integer
                  description: >-
                    An upper bound for the number of tokens that can be
                    generated for a response, including visible output tokens
                    and reasoning tokens.
                max_tool_calls:
                  type: integer
                  description: >-
                    The maximum number of total calls to built-in tools that can
                    be processed in a response. This limit applies across all
                    built-in tool calls, not per individual tool. Any further
                    tool call attempts by the model will be ignored.
                metadata:
                  type: object
                  description: >-
                    Set of up to 16 key-value pairs that can be attached to the
                    response. Useful for storing additional information in a
                    structured format. Keys have a maximum length of 64
                    characters; values have a maximum length of 512 characters.
                  additionalProperties:
                    type: string
                parallel_tool_calls:
                  type: boolean
                  description: Whether to allow the model to run tool calls in parallel.
                  default: true
                previous_response_id:
                  type: string
                  description: >-
                    The unique ID of a previous response. Use this to create
                    multi-turn conversations without manually managing
                    conversation state. Cannot be used with `conversation`.
                prompt:
                  type: object
                  description: Reference to a prompt template and its variables.
                  properties:
                    id:
                      type: string
                      description: The ID of the prompt template.
                    variables:
                      type: object
                      description: Key-value pairs for template variables.
                      additionalProperties:
                        type: string
                    version:
                      type: string
                      description: The version of the prompt template to use.
                prompt_cache_key:
                  type: string
                  description: >-
                    A key used to cache responses for similar requests, helping
                    optimize cache hit rates. Replaces the deprecated `user`
                    field for caching purposes.
                prompt_cache_retention:
                  type: string
                  description: >-
                    The retention policy for the prompt cache. Set to `24h` to
                    keep cached prefixes active for up to 24 hours.
                  enum:
                    - in-memory
                    - 24h
                reasoning:
                  type: object
                  description: >-
                    Configuration options for reasoning models (o-series and
                    gpt-5). Controls the depth of reasoning before generating a
                    response.
                  properties:
                    effort:
                      type: string
                      description: >-
                        Constrains effort on reasoning. Reducing reasoning
                        effort can result in faster responses and fewer tokens
                        used on reasoning.
                      enum:
                        - none
                        - minimal
                        - low
                        - medium
                        - high
                    generate_summary:
                      type: string
                      description: Whether to generate a summary of the reasoning process.
                      enum:
                        - auto
                        - concise
                        - detailed
                    summary:
                      type: string
                      description: Deprecated. Use `generate_summary` instead.
                      enum:
                        - auto
                        - concise
                        - detailed
                      deprecated: true
                safety_identifier:
                  type: string
                  description: >-
                    A stable identifier for your end-users, used to help detect
                    policy violations. Should be a hashed username or email — do
                    not send identifying information directly.
                  maxLength: 64
                service_tier:
                  type: string
                  description: >-
                    Specifies the processing tier for the request. When set, the
                    response will include the actual `service_tier` used.


                    - `auto`: Uses the tier configured in project settings
                    (default behavior).

                    - `default`: Standard pricing and performance.

                    - `flex`: Flexible processing with potential cost savings.

                    - `priority`: Priority processing with faster response
                    times.
                  enum:
                    - auto
                    - default
                    - flex
                    - priority
                store:
                  type: boolean
                  description: >-
                    Whether to store the generated response for later retrieval
                    via API.
                  default: true
                stream:
                  type: boolean
                  description: >-
                    If set to `true`, the response data will be streamed to the
                    client as it is generated using server-sent events (SSE).
                    Events include `response.created`,
                    `response.output_text.delta`, `response.completed`, and
                    more.
                  default: false
                stream_options:
                  type: object
                  description: >-
                    Options for streaming responses. Only set this when `stream`
                    is `true`.
                  properties:
                    include_obfuscation:
                      type: boolean
                      description: Whether to include obfuscation data in streaming events.
                temperature:
                  type: number
                  description: >-
                    Sampling temperature between 0 and 2. Higher values (e.g.,
                    0.8) increase randomness; lower values (e.g., 0.2) make
                    output more focused and deterministic. We recommend
                    adjusting either this or `top_p`, but not both.
                  default: 1
                  minimum: 0
                  maximum: 2
                text:
                  type: object
                  description: >-
                    Configuration for text output. Use this to request
                    structured JSON output via JSON mode or JSON Schema.
                  properties:
                    format:
                      type: object
                      description: The format of the text output.
                      properties:
                        type:
                          type: string
                          description: >-
                            The output format type. `text` returns plain text,
                            `json_object` returns valid JSON, `json_schema`
                            returns JSON conforming to a provided schema.
                          enum:
                            - text
                            - json_object
                            - json_schema
                        json_schema:
                          type: object
                          description: >-
                            The JSON Schema to use when `type` is `json_schema`.
                            Required when using structured outputs.
                    verbosity:
                      type: string
                      description: Controls the verbosity of the text output.
                      enum:
                        - low
                        - medium
                        - high
                tool_choice:
                  type:
                    - string
                    - object
                  description: >-
                    Controls how the model selects which tool(s) to call.


                    - `auto` (default): The model decides whether and which
                    tools to call.

                    - `none`: The model will not call any tools.

                    - `required`: The model must call at least one tool.

                    - An object specifying a particular tool to use.
                  default: auto
                tools:
                  type: array
                  description: >-
                    An array of tools the model may call while generating a
                    response. CometAPI supports three categories:


                    - **Built-in tools**: Platform-provided tools like
                    `web_search_preview` and `file_search`.

                    - **Function calls**: Custom functions you define, enabling
                    the model to call your own code with structured arguments.

                    - **MCP tools**: Integrations with third-party systems via
                    MCP servers.
                  items:
                    type: object
                top_logprobs:
                  type: integer
                  description: >-
                    Number of most likely tokens to return at each position
                    (0–20), each with an associated log probability. Must
                    include `message.output_text.logprobs` in the `include`
                    parameter to receive logprobs.
                  minimum: 0
                  maximum: 20
                top_p:
                  type: number
                  description: >-
                    Nucleus sampling parameter. The model considers tokens with
                    `top_p` cumulative probability mass. For example, 0.1 means
                    only the top 10% probability tokens are considered. We
                    recommend adjusting either this or `temperature`, but not
                    both.
                  default: 1
                  minimum: 0
                  maximum: 1
                truncation:
                  type: string
                  description: >-
                    The truncation strategy for handling inputs that exceed the
                    model's context window.


                    - `auto`: The model truncates the input by dropping items
                    from the beginning of the conversation to fit.

                    - `disabled` (default): The request fails with a 400 error
                    if the input exceeds the context window.
                  enum:
                    - auto
                    - disabled
                  default: disabled
                user:
                  type: string
                  description: >-
                    Deprecated. Use `safety_identifier` and `prompt_cache_key`
                    instead. A stable identifier for your end-user.
                  deprecated: true
            examples:
              Text Input:
                summary: Text Input
                value:
                  model: gpt-5.4
                  input: Tell me a three sentence bedtime story about a unicorn.
              Image Input:
                summary: Image Input
                value:
                  model: gpt-5.4
                  input:
                    - role: user
                      content:
                        - type: input_text
                          text: What is in this image?
                        - type: input_image
                          image_url: >-
                            https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg
              File Input:
                summary: File Input
                value:
                  model: gpt-5.4
                  input:
                    - role: user
                      content:
                        - type: input_text
                          text: What is in this file?
                        - type: input_file
                          file_url: >-
                            https://www.berkshirehathaway.com/letters/2024ltr.pdf
              Function Calling:
                summary: Function Calling
                value:
                  model: gpt-5.4
                  input: What is the weather like in Boston today?
                  tools:
                    - type: function
                      name: get_current_weather
                      description: Get the current weather in a given location
                      parameters:
                        type: object
                        properties:
                          location:
                            type: string
                            description: The city and state, e.g. San Francisco, CA
                          unit:
                            type: string
                            enum:
                              - celsius
                              - fahrenheit
                        required:
                          - location
                          - unit
              Reasoning:
                summary: Reasoning
                value:
                  model: o4-mini
                  input: 'Solve step by step: What is 15% of 240?'
                  reasoning:
                    effort: high
      responses:
        '200':
          description: The generated Response object.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Unique identifier for the response.
                    example: resp_0a153ae8201f73bc0069a7e8044cc481
                  object:
                    type: string
                    description: The object type, always `response`.
                    enum:
                      - response
                    example: response
                  created_at:
                    type: integer
                    description: >-
                      Unix timestamp (in seconds) of when the response was
                      created.
                    example: 1772611588
                  status:
                    type: string
                    description: The status of the response.
                    enum:
                      - completed
                      - in_progress
                      - failed
                      - cancelled
                      - queued
                    example: completed
                  background:
                    type: boolean
                    description: Whether the response was run in the background.
                    example: false
                  completed_at:
                    type:
                      - integer
                      - 'null'
                    description: >-
                      Unix timestamp of when the response was completed, or
                      `null` if still in progress.
                    example: 1772611589
                  error:
                    type:
                      - object
                      - 'null'
                    description: >-
                      Error information if the response failed, or `null` on
                      success.
                    properties:
                      code:
                        type: string
                        description: The error code.
                      message:
                        type: string
                        description: A human-readable error message.
                  incomplete_details:
                    type:
                      - object
                      - 'null'
                    description: >-
                      Details about why the response is incomplete, if
                      applicable.
                    properties:
                      reason:
                        type: string
                        description: The reason the response is incomplete.
                        enum:
                          - max_output_tokens
                          - content_filter
                  instructions:
                    type:
                      - string
                      - 'null'
                    description: The system instructions used for this response.
                  max_output_tokens:
                    type:
                      - integer
                      - 'null'
                    description: The maximum output token limit that was applied.
                  model:
                    type: string
                    description: The model used for the response.
                    example: gpt-4.1-nano
                  output:
                    type: array
                    description: >-
                      An array of output items generated by the model. Each item
                      can be a message, function call, or other output type.
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Unique identifier for the output item.
                        type:
                          type: string
                          description: The type of output item.
                          enum:
                            - message
                            - function_call
                            - web_search_call
                            - file_search_call
                            - code_interpreter_call
                            - computer_call
                            - reasoning
                        status:
                          type: string
                          description: The status of this output item.
                          enum:
                            - completed
                            - in_progress
                        role:
                          type: string
                          description: >-
                            The role of the message (present when `type` is
                            `message`).
                          enum:
                            - assistant
                        content:
                          type: array
                          description: >-
                            The content parts of the message (present when
                            `type` is `message`).
                          items:
                            type: object
                            properties:
                              type:
                                type: string
                                description: The content type.
                                enum:
                                  - output_text
                              text:
                                type: string
                                description: The generated text content.
                              annotations:
                                type: array
                                description: >-
                                  Annotations such as file citations or URL
                                  citations.
                                items:
                                  type: object
                              logprobs:
                                type: array
                                description: >-
                                  Log probability information (when requested
                                  via `include`).
                                items:
                                  type: object
                        name:
                          type: string
                          description: >-
                            The name of the function being called (present when
                            `type` is `function_call`).
                        arguments:
                          type: string
                          description: >-
                            The JSON-encoded arguments for the function call
                            (present when `type` is `function_call`).
                        call_id:
                          type: string
                          description: >-
                            The unique call identifier (present when `type` is
                            `function_call`).
                  output_text:
                    type: string
                    description: >-
                      A convenience field containing the concatenated text
                      output from all output message items.
                  parallel_tool_calls:
                    type: boolean
                    description: Whether parallel tool calls were enabled.
                  previous_response_id:
                    type:
                      - string
                      - 'null'
                    description: >-
                      The ID of the previous response, if this is a multi-turn
                      conversation.
                  reasoning:
                    type: object
                    description: The reasoning configuration that was used.
                    properties:
                      effort:
                        type:
                          - string
                          - 'null'
                        description: The reasoning effort level.
                      summary:
                        type:
                          - string
                          - 'null'
                        description: The reasoning summary setting.
                  service_tier:
                    type: string
                    description: The service tier actually used to process the request.
                    example: default
                  store:
                    type: boolean
                    description: Whether the response was stored.
                  temperature:
                    type: number
                    description: The temperature value used.
                    example: 1
                  text:
                    type: object
                    description: The text configuration used.
                    properties:
                      format:
                        type: object
                        properties:
                          type:
                            type: string
                      verbosity:
                        type: string
                        description: The verbosity level used.
                  tool_choice:
                    type:
                      - string
                      - object
                    description: The tool choice setting used.
                  tools:
                    type: array
                    description: The tools that were available for this response.
                    items:
                      type: object
                  top_p:
                    type: number
                    description: The `top_p` value used.
                    example: 1
                  truncation:
                    type: string
                    description: The truncation strategy used.
                  usage:
                    type: object
                    description: Token usage statistics for this response.
                    properties:
                      input_tokens:
                        type: integer
                        description: Number of input tokens consumed.
                        example: 19
                      input_tokens_details:
                        type: object
                        description: Breakdown of input token usage.
                        properties:
                          cached_tokens:
                            type: integer
                            description: Number of input tokens that were cached.
                            example: 0
                      output_tokens:
                        type: integer
                        description: Number of output tokens generated.
                        example: 9
                      output_tokens_details:
                        type: object
                        description: Breakdown of output token usage.
                        properties:
                          reasoning_tokens:
                            type: integer
                            description: Number of tokens used for reasoning.
                            example: 0
                      total_tokens:
                        type: integer
                        description: Total number of tokens (input + output).
                        example: 28
                  user:
                    type:
                      - string
                      - 'null'
                    description: The user identifier, if provided.
                  metadata:
                    type: object
                    description: The metadata attached to this response.
                    additionalProperties:
                      type: string
                  content_filters:
                    type:
                      - array
                      - 'null'
                    description: Content filter results applied to the response, if any.
                    nullable: true
                  frequency_penalty:
                    type: number
                    description: The frequency penalty applied to the request.
                    default: 0
                  max_tool_calls:
                    type:
                      - integer
                      - 'null'
                    description: Maximum number of tool calls allowed, if set.
                    nullable: true
                  presence_penalty:
                    type: number
                    description: The presence penalty applied to the request.
                    default: 0
                  prompt_cache_key:
                    type:
                      - string
                      - 'null'
                    description: Cache key for prompt caching, if applicable.
                    nullable: true
                  prompt_cache_retention:
                    type:
                      - string
                      - 'null'
                    description: Prompt cache retention policy, if applicable.
                    nullable: true
                  safety_identifier:
                    type:
                      - string
                      - 'null'
                    description: Safety system identifier for the response, if applicable.
                    nullable: true
                  top_logprobs:
                    type: integer
                    description: >-
                      Number of top log probabilities returned per token
                      position.
                    default: 0
              example:
                id: resp_0a153ae8201f73bc0069a7e8044cc481
                object: response
                created_at: 1772611588
                status: completed
                background: false
                completed_at: 1772611589
                error: null
                incomplete_details: null
                instructions: null
                max_output_tokens: null
                model: gpt-4.1-nano
                output:
                  - id: msg_0a153ae8201f73bc0069a7e8049a8881
                    type: message
                    status: completed
                    content:
                      - type: output_text
                        annotations: []
                        text: Four.
                    role: assistant
                parallel_tool_calls: true
                previous_response_id: null
                prompt_cache_key: null
                prompt_cache_retention: null
                reasoning:
                  effort: null
                  summary: null
                safety_identifier: null
                service_tier: auto
                store: true
                temperature: 1
                text:
                  format:
                    type: text
                  verbosity: medium
                tool_choice: auto
                tools: []
                top_p: 1
                truncation: disabled
                usage:
                  input_tokens: 19
                  input_tokens_details:
                    cached_tokens: 0
                  output_tokens: 9
                  output_tokens_details:
                    reasoning_tokens: 0
                  total_tokens: 28
                user: null
                metadata: {}
      x-codeSamples:
        - lang: Python
          label: Text Input
          source: |
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key="<COMETAPI_KEY>",
            )

            response = client.responses.create(
                model="gpt-5.4",
                input="Tell me a three sentence bedtime story about a unicorn.",
            )

            print(response.output_text)
        - lang: Python
          label: Image Input
          source: |
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key="<COMETAPI_KEY>",
            )

            response = client.responses.create(
                model="gpt-5.4",
                input=[
                    {
                        "role": "user",
                        "content": [
                            {"type": "input_text", "text": "What is in this image?"},
                            {
                                "type": "input_image",
                                "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
                            },
                        ],
                    }
                ],
            )

            print(response.output_text)
        - lang: Python
          label: File Input
          source: |
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key="<COMETAPI_KEY>",
            )

            response = client.responses.create(
                model="gpt-5.4",
                input=[
                    {
                        "role": "user",
                        "content": [
                            {"type": "input_text", "text": "What is in this file?"},
                            {
                                "type": "input_file",
                                "file_url": "https://www.berkshirehathaway.com/letters/2024ltr.pdf",
                            },
                        ],
                    }
                ],
            )

            print(response.output_text)
        - lang: Python
          label: Web Search
          source: |
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key="<COMETAPI_KEY>",
            )

            response = client.responses.create(
                model="gpt-5.4",
                tools=[{"type": "web_search_preview"}],
                input="What was a positive news story from today?",
            )

            print(response.output_text)
        - lang: Python
          label: Streaming
          source: |
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key="<COMETAPI_KEY>",
            )

            stream = client.responses.create(
                model="gpt-5.4",
                input="Tell me a three sentence bedtime story about a unicorn.",
                stream=True,
            )

            for event in stream:
                print(event)
        - lang: Python
          label: Functions
          source: |
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key="<COMETAPI_KEY>",
            )

            response = client.responses.create(
                model="gpt-5.4",
                input="What is the weather like in Boston today?",
                tools=[
                    {
                        "type": "function",
                        "name": "get_current_weather",
                        "description": "Get the current weather in a given location",
                        "parameters": {
                            "type": "object",
                            "properties": {
                                "location": {
                                    "type": "string",
                                    "description": "The city and state, e.g. San Francisco, CA",
                                },
                                "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
                            },
                            "required": ["location", "unit"],
                        },
                    }
                ],
            )

            print(response.output)
        - lang: Python
          label: Reasoning
          source: |
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key="<COMETAPI_KEY>",
            )

            response = client.responses.create(
                model="o4-mini",
                input="How much wood would a woodchuck chuck?",
                reasoning={"effort": "high"},
            )

            print(response.output_text)
        - lang: JavaScript
          label: Text Input
          source: |
            import OpenAI from "openai";

            const client = new OpenAI({
                baseURL: "https://api.cometapi.com/v1",
                apiKey: "<COMETAPI_KEY>",
            });

            const response = await client.responses.create({
                model: "gpt-5.4",
                input: "Tell me a three sentence bedtime story about a unicorn.",
            });

            console.log(response.output_text);
        - lang: JavaScript
          label: Image Input
          source: |
            import OpenAI from "openai";

            const client = new OpenAI({
                baseURL: "https://api.cometapi.com/v1",
                apiKey: "<COMETAPI_KEY>",
            });

            const response = await client.responses.create({
                model: "gpt-5.4",
                input: [
                    {
                        role: "user",
                        content: [
                            { type: "input_text", text: "What is in this image?" },
                            {
                                type: "input_image",
                                image_url: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
                            },
                        ],
                    },
                ],
            });

            console.log(response.output_text);
        - lang: JavaScript
          label: File Input
          source: |
            import OpenAI from "openai";

            const client = new OpenAI({
                baseURL: "https://api.cometapi.com/v1",
                apiKey: "<COMETAPI_KEY>",
            });

            const response = await client.responses.create({
                model: "gpt-5.4",
                input: [
                    {
                        role: "user",
                        content: [
                            { type: "input_text", text: "What is in this file?" },
                            {
                                type: "input_file",
                                file_url: "https://www.berkshirehathaway.com/letters/2024ltr.pdf",
                            },
                        ],
                    },
                ],
            });

            console.log(response.output_text);
        - lang: JavaScript
          label: Web Search
          source: |
            import OpenAI from "openai";

            const client = new OpenAI({
                baseURL: "https://api.cometapi.com/v1",
                apiKey: "<COMETAPI_KEY>",
            });

            const response = await client.responses.create({
                model: "gpt-5.4",
                tools: [{ type: "web_search_preview" }],
                input: "What was a positive news story from today?",
            });

            console.log(response.output_text);
        - lang: JavaScript
          label: Streaming
          source: |
            import OpenAI from "openai";

            const client = new OpenAI({
                baseURL: "https://api.cometapi.com/v1",
                apiKey: "<COMETAPI_KEY>",
            });

            const stream = await client.responses.create({
                model: "gpt-5.4",
                input: "Tell me a three sentence bedtime story about a unicorn.",
                stream: true,
            });

            for await (const event of stream) {
                if (event.type === "response.output_text.delta") {
                    process.stdout.write(event.delta);
                }
            }
        - lang: JavaScript
          label: Functions
          source: |
            import OpenAI from "openai";

            const client = new OpenAI({
                baseURL: "https://api.cometapi.com/v1",
                apiKey: "<COMETAPI_KEY>",
            });

            const response = await client.responses.create({
                model: "gpt-5.4",
                input: "What is the weather like in Boston today?",
                tools: [
                    {
                        type: "function",
                        name: "get_current_weather",
                        description: "Get the current weather in a given location",
                        parameters: {
                            type: "object",
                            properties: {
                                location: { type: "string", description: "The city and state" },
                                unit: { type: "string", enum: ["celsius", "fahrenheit"] },
                            },
                            required: ["location", "unit"],
                        },
                    },
                ],
            });

            console.log(response.output);
        - lang: JavaScript
          label: Reasoning
          source: |
            import OpenAI from "openai";

            const client = new OpenAI({
                baseURL: "https://api.cometapi.com/v1",
                apiKey: "<COMETAPI_KEY>",
            });

            const response = await client.responses.create({
                model: "o4-mini",
                input: "How much wood would a woodchuck chuck?",
                reasoning: { effort: "high" },
            });

            console.log(response.output_text);
        - lang: Shell
          label: Text Input
          source: |
            curl https://api.cometapi.com/v1/responses \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer <COMETAPI_KEY>" \
              -d '{
                "model": "gpt-5.4",
                "input": "Tell me a three sentence bedtime story about a unicorn."
              }'
        - lang: Shell
          label: Image Input
          source: |
            curl https://api.cometapi.com/v1/responses \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer <COMETAPI_KEY>" \
              -d '{
                "model": "gpt-5.4",
                "input": [
                  {
                    "role": "user",
                    "content": [
                      {"type": "input_text", "text": "What is in this image?"},
                      {"type": "input_image", "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"}
                    ]
                  }
                ]
              }'
        - lang: Shell
          label: File Input
          source: |
            curl https://api.cometapi.com/v1/responses \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer <COMETAPI_KEY>" \
              -d '{
                "model": "gpt-5.4",
                "input": [
                  {
                    "role": "user",
                    "content": [
                      {"type": "input_text", "text": "What is in this file?"},
                      {"type": "input_file", "file_url": "https://www.berkshirehathaway.com/letters/2024ltr.pdf"}
                    ]
                  }
                ]
              }'
        - lang: Shell
          label: Web Search
          source: |
            curl https://api.cometapi.com/v1/responses \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer <COMETAPI_KEY>" \
              -d '{
                "model": "gpt-5.4",
                "tools": [{"type": "web_search_preview"}],
                "input": "What was a positive news story from today?"
              }'
        - lang: Shell
          label: Streaming
          source: |
            curl https://api.cometapi.com/v1/responses \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer <COMETAPI_KEY>" \
              -d '{
                "model": "gpt-5.4",
                "input": "Tell me a three sentence bedtime story about a unicorn.",
                "stream": true
              }'
        - lang: Shell
          label: Functions
          source: |
            curl https://api.cometapi.com/v1/responses \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer <COMETAPI_KEY>" \
              -d '{
                "model": "gpt-5.4",
                "input": "What is the weather like in Boston today?",
                "tools": [
                  {
                    "type": "function",
                    "name": "get_current_weather",
                    "description": "Get the current weather in a given location",
                    "parameters": {
                      "type": "object",
                      "properties": {
                        "location": {"type": "string", "description": "The city and state"},
                        "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
                      },
                      "required": ["location", "unit"]
                    }
                  }
                ]
              }'
        - lang: Shell
          label: Reasoning
          source: |
            curl https://api.cometapi.com/v1/responses \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer <COMETAPI_KEY>" \
              -d '{
                "model": "o4-mini",
                "input": "How much wood would a woodchuck chuck?",
                "reasoning": {"effort": "high"}
              }'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````