> ## 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.

# Opprett et modellsvar

> Bruk CometAPI POST /v1/responses til å opprette Multimodal-modellsvar og samtalehistorikk med innebygde verktøy og function calling.

Bruk Responses API til å sende tekst, bilder, filer og samtalehistorikk med `gpt-6-astra`. Eksemplene viser også nettsøk, egendefinerte function calls, strukturert utdata, resonnering og streaming.

<Note>
  Den [OpenAI Responses-referansen](https://developers.openai.com/api/reference/typescript/resources/responses/methods/create) beskriver hele API-formatet; eksemplene her konfigurerer dette formatet for CometAPI.
</Note>

***

## Fortsett en samtale

For en samtale som kun består av tekst, behold brukermeldingene og assistentens tekstsvar, og legg deretter til den neste brukermeldingen:

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

client = OpenAI(
    base_url="https://api.cometapi.com/v1",
    api_key=os.environ["COMETAPI_KEY"],
)

input_items = [
    {"role": "user", "content": "My project is named Cedar and uses Python. Remember these two facts."}
]

response = client.responses.create(
    model="gpt-6-astra",
    input=input_items,
    reasoning={"effort": "low"},
)

input_items.append({"role": "assistant", "content": response.output_text})
input_items.append({
    "role": "user",
    "content": "What is my project's name and programming language?",
})

follow_up = client.responses.create(
    model="gpt-6-astra",
    input=input_items,
    reasoning={"effort": "low"},
)

print(follow_up.output_text)

```

`response.output_text` er en praktisk SDK-egenskap som kombinerer assistenttekst fra svaret. Samtaler med function calling trenger også elementene for verktøykall og resultater, som beskrevet nedenfor.

***

## Bruk nettsøk

Legg til et `web_search`-verktøy for å søke etter informasjon og inkludere kildehenvisninger:

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

client = OpenAI(
    base_url="https://api.cometapi.com/v1",
    api_key=os.environ["COMETAPI_KEY"],
)

response = client.responses.create(
    model="gpt-6-astra",
    input="Search the web for the NASA Artemis II mission overview and cite the official NASA page.",
    tools=[
        {
            "type": "web_search",
        },
    ],
    reasoning={
        "effort": "low",
    },
)

print(response.output_text)

```

Undersøk de returnerte `web_search_call`-elementene og URL-merknadene i meldingen når applikasjonen din trenger søkeresultater eller kildehenvisninger. Andre innebygde verktøy krever egen konfigurasjon; se [OpenAI-verktøyguiden](https://developers.openai.com/api/docs/guides/tools).

***

## Kall egendefinerte funksjoner

Definer funksjonsargumentene, og la modellen be om funksjonen:

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

client = OpenAI(
    base_url="https://api.cometapi.com/v1",
    api_key=os.environ["COMETAPI_KEY"],
)

response = client.responses.create(
    model="gpt-6-astra",
    input="What is the weather in Boston, MA, in celsius? Use the weather tool.",
    tools=[
        {
            "type": "function",
            "name": "get_current_weather",
            "description": "Get the current weather for a city.",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "City and state, for example Boston, MA.",
                    },
                    "unit": {
                        "type": "string",
                        "enum": [
                            "celsius",
                            "fahrenheit",
                        ],
                        "description": "Temperature unit.",
                    },
                },
                "required": [
                    "location",
                    "unit",
                ],
                "additionalProperties": False,
            },
            "strict": True,
        },
    ],
    tool_choice="auto",
    reasoning={
        "effort": "low",
    },
)

print(response.output)

```

Et funksjonskall vises som et `function_call`-utdataelement. Feltet `arguments` er en JSON-kodet streng. Kjør funksjonen din, og bygg deretter den neste forespørselen fra den opprinnelige inndataen og returnerte utdataelementer uten respons-elementenes `id`-felt. Behold funksjonens `name`, `arguments` og `call_id`, og legg til et `function_call_output`-element med den samsvarende `call_id` og resultatet ditt i `output`.

***

## Be om strukturert utdata

Bruk `text.format` til å be om JSON som følger et skjema:

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

client = OpenAI(
    base_url="https://api.cometapi.com/v1",
    api_key=os.environ["COMETAPI_KEY"],
)

response = client.responses.create(
    model="gpt-6-astra",
    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",
                                    "description": "Programming language name.",
                                },
                                "use_case": {
                                    "type": "string",
                                    "description": "Main use case for the language.",
                                },
                            },
                            "required": [
                                "name",
                                "use_case",
                            ],
                            "additionalProperties": False,
                        },
                        "description": "Three programming languages and their main uses.",
                    },
                },
                "required": [
                    "languages",
                ],
                "additionalProperties": False,
            },
        },
    },
    reasoning={
        "effort": "low",
    },
)

print(response.output_text)

```

Kontroller at responsen ble fullført og ikke avslo forespørselen før du tolker JSON-en. En respons som når grensen for output-Tokens, kan være ufullstendig.

***

## Konfigurer resonnering

Angi `reasoning.effort` for å velge modellens resonneringsinnsats:

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

client = OpenAI(
    base_url="https://api.cometapi.com/v1",
    api_key=os.environ["COMETAPI_KEY"],
)

response = client.responses.create(
    model="gpt-6-astra",
    input="Solve this step by step: what is 15% of 240?",
    reasoning={
        "effort": "high",
    },
)

print(response.output_text)

```

Eksemplene bruker `low` for generelle oppgaver og `high` for resonneringseksempelet. `max_output_tokens` inkluderer både reasoning og synlige output Tokens.

***

## Strøm Responses

Angi `stream` til `true` for å motta server-sendte hendelser:

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

client = OpenAI(
    base_url="https://api.cometapi.com/v1",
    api_key=os.environ["COMETAPI_KEY"],
)

stream = client.responses.create(
    model="gpt-6-astra",
    input="Tell me a three sentence bedtime story about a unicorn.",
    reasoning={
        "effort": "low",
    },
    stream=True,
)

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

```

Et tekstsvar inkluderer livssyklushendelser som `response.created`, `response.in_progress` og `response.completed`. Tekst kommer i `response.output_text.delta`-hendelser. Verktøy- og resonneringshendelser avhenger av forespørselen, så håndter hendelser etter `type` i stedet for å anta at alle Responses har samme sekvens.

***

<Tip>
  Se OpenAI-guidene for [bildeinndata](https://developers.openai.com/api/docs/guides/images-vision), [filinndata](https://developers.openai.com/api/docs/guides/file-inputs), [strukturerte utdata](https://developers.openai.com/api/docs/guides/structured-outputs), [Function Calling](https://developers.openai.com/api/docs/guides/function-calling), [samtaletilstand](https://developers.openai.com/api/docs/guides/conversation-state), og [resonnering](https://developers.openai.com/api/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
      description: >-
        Send text, images, files, or conversation history to a model with the
        Responses API.
      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-6-astra
                  default: gpt-6-astra
                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.
                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`.
                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.
                previous_response_id:
                  type: string
                  description: >-
                    An ID for a stored response that is accessible to the
                    selected model and request context. Cannot be combined with
                    conversation. The conversation-history example sends prior
                    input and output items explicitly.
                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: >-
                    Legacy prompt-cache retention setting. Refer to the selected
                    model documentation for prompt_cache_options and supported
                    retention settings.
                  enum:
                    - in_memory
                    - 24h
                  deprecated: true
                reasoning:
                  type: object
                  description: Reasoning configuration for the selected model.
                  properties:
                    effort:
                      type: string
                      description: >-
                        Model-dependent reasoning effort. The examples use low
                        for general tasks and high for the reasoning example.
                        See the selected model reference for supported levels.
                    generate_summary:
                      type: string
                      description: >-
                        Deprecated alias. Use summary for a reasoning summary
                        when supported.
                      enum:
                        - auto
                        - concise
                        - detailed
                      deprecated: true
                    summary:
                      type: string
                      description: >-
                        Request a summary of the model reasoning when supported
                        by the selected model.
                      enum:
                        - auto
                        - concise
                        - detailed
                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: >-
                    Request response storage for later retrieval, when supported
                    by the selected model and request context.
                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.
                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. Omit this field for GPT-6 Astra.
                  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
                        name:
                          type: string
                          description: Name of the output schema when type is json_schema.
                        schema:
                          type: object
                          description: >-
                            JSON Schema describing the requested output when
                            type is json_schema.
                        strict:
                          type: boolean
                          description: >-
                            Require the supported JSON Schema to be followed for
                            a completed, non-refusal structured response.
                    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.
                tools:
                  type: array
                  description: >-
                    Tools available to the model. This page demonstrates
                    web_search and custom function tools. Other tool types
                    require their own configuration; see the official tool
                    reference.
                  items:
                    type: object
                top_logprobs:
                  type: integer
                  description: >-
                    Number of token alternatives to include for models
                    supporting log probabilities. Requires
                    message.output_text.logprobs in include. Omit for GPT-6
                    Astra.
                  minimum: 0
                  maximum: 20
                top_p:
                  type: number
                  description: >-
                    Nucleus sampling threshold. Omit this field for GPT-6 Astra.
                    For sampling overrides, adjust either top_p or temperature.
                  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
                user:
                  type: string
                  description: >-
                    Deprecated. Use `safety_identifier` and `prompt_cache_key`
                    instead. A stable identifier for your end-user.
                  deprecated: true
              default:
                model: gpt-6-astra
                input: Tell me a three sentence bedtime story about a unicorn.
                reasoning:
                  effort: low
            examples:
              Text Input:
                summary: Text Input
                value:
                  model: gpt-6-astra
                  input: Tell me a three sentence bedtime story about a unicorn.
                  reasoning:
                    effort: low
              Image Input:
                summary: Image Input
                value:
                  model: gpt-6-astra
                  input:
                    - role: user
                      content:
                        - type: input_text
                          text: >-
                            Describe the road and surrounding landscape in this
                            image.
                        - type: input_image
                          image_url: >-
                            https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?w=1200
                  reasoning:
                    effort: low
              File Input:
                summary: File Input
                value:
                  model: gpt-6-astra
                  input:
                    - role: user
                      content:
                        - type: input_text
                          text: >-
                            Summarize the main topics in this shareholder
                            letter.
                        - type: input_file
                          file_url: >-
                            https://www.berkshirehathaway.com/letters/2024ltr.pdf
                  reasoning:
                    effort: low
              Web Search:
                summary: Web Search
                value:
                  model: gpt-6-astra
                  input: >-
                    Search the web for the NASA Artemis II mission overview and
                    cite the official NASA page.
                  tools:
                    - type: web_search
                  reasoning:
                    effort: low
              Streaming:
                summary: Streaming
                value:
                  model: gpt-6-astra
                  input: Tell me a three sentence bedtime story about a unicorn.
                  reasoning:
                    effort: low
                  stream: true
              Functions:
                summary: Functions
                value:
                  model: gpt-6-astra
                  input: >-
                    What is the weather in Boston, MA, in celsius? Use the
                    weather tool.
                  tools:
                    - type: function
                      name: get_current_weather
                      description: Get the current weather for a city.
                      parameters:
                        type: object
                        properties:
                          location:
                            type: string
                            description: City and state, for example Boston, MA.
                          unit:
                            type: string
                            enum:
                              - celsius
                              - fahrenheit
                            description: Temperature unit.
                        required:
                          - location
                          - unit
                        additionalProperties: false
                      strict: true
                  tool_choice: auto
                  reasoning:
                    effort: low
              Reasoning:
                summary: Reasoning
                value:
                  model: gpt-6-astra
                  input: 'Solve this step by step: what is 15% of 240?'
                  reasoning:
                    effort: high
              Structured Output:
                summary: Structured Output
                value:
                  model: gpt-6-astra
                  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
                                  description: Programming language name.
                                use_case:
                                  type: string
                                  description: Main use case for the language.
                              required:
                                - name
                                - use_case
                              additionalProperties: false
                            description: Three programming languages and their main uses.
                        required:
                          - languages
                        additionalProperties: false
                  reasoning:
                    effort: low
      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_example
                  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: 1788763707
                  status:
                    type: string
                    description: The status of the response.
                    enum:
                      - completed
                      - in_progress
                      - failed
                      - cancelled
                      - queued
                      - incomplete
                    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: 1788763711
                  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-6-astra
                  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`).
                        phase:
                          type: string
                          description: >-
                            Message phase reported by the model, such as
                            final_answer.
                  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.
                      context:
                        type:
                          - string
                          - 'null'
                        description: Reasoning context mode reported by the model.
                      mode:
                        type:
                          - string
                          - 'null'
                        description: Reasoning execution mode reported by the model.
                  service_tier:
                    type: string
                    description: The service tier actually used to process the request.
                  store:
                    type: boolean
                    description: Whether the response was stored.
                  temperature:
                    type: number
                    description: The temperature value used.
                  text:
                    type: object
                    description: The text configuration used.
                    properties:
                      format:
                        type: object
                        properties:
                          type:
                            type: string
                            description: >-
                              Format type: `text` (default), `json_object`, or
                              `json_schema`.
                        description: Output text format configuration.
                      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.
                  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: 17
                      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
                          cache_write_tokens:
                            type: integer
                            description: >-
                              Input tokens written to the prompt cache, when
                              reported.
                      output_tokens:
                        type: integer
                        description: Number of output tokens generated.
                        example: 81
                      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: 98
                  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.
                  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.
                  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.
              example:
                id: resp_example
                object: response
                created_at: 1788763707
                status: completed
                background: false
                completed_at: 1788763711
                error: null
                incomplete_details: null
                model: gpt-6-astra
                output:
                  - id: msg_example
                    type: message
                    status: completed
                    content:
                      - type: output_text
                        annotations: []
                        logprobs: []
                        text: >-
                          A little unicorn named Luna followed a trail of silver
                          fireflies to a meadow where the flowers chimed softly
                          in the breeze. She curled beneath a willow tree,
                          tucked her hooves into the cool grass, and wished
                          sweet dreams for every creature in the forest. As the
                          moon wrapped the meadow in gentle light, Luna closed
                          her eyes and drifted into dreams of dancing among the
                          stars.
                    phase: final_answer
                    role: assistant
                parallel_tool_calls: true
                previous_response_id: null
                reasoning:
                  context: all_turns
                  effort: low
                  mode: standard
                  summary: null
                store: true
                text:
                  format:
                    type: text
                  verbosity: medium
                tool_choice: auto
                tools: []
                usage:
                  input_tokens: 17
                  input_tokens_details:
                    cache_write_tokens: 0
                    cached_tokens: 0
                  output_tokens: 81
                  output_tokens_details:
                    reasoning_tokens: 0
                  total_tokens: 98
      x-codeSamples:
        - lang: Python
          label: Text Input
          source: |
            import os
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key=os.environ["COMETAPI_KEY"],
            )

            response = client.responses.create(
                model="gpt-6-astra",
                input="Tell me a three sentence bedtime story about a unicorn.",
                reasoning={
                    "effort": "low",
                },
            )

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

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key=os.environ["COMETAPI_KEY"],
            )

            response = client.responses.create(
                model="gpt-6-astra",
                input=[
                    {
                        "role": "user",
                        "content": [
                            {
                                "type": "input_text",
                                "text": "Describe the road and surrounding landscape in this image.",
                            },
                            {
                                "type": "input_image",
                                "image_url": "https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?w=1200",
                            },
                        ],
                    },
                ],
                reasoning={
                    "effort": "low",
                },
            )

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

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key=os.environ["COMETAPI_KEY"],
            )

            response = client.responses.create(
                model="gpt-6-astra",
                input=[
                    {
                        "role": "user",
                        "content": [
                            {
                                "type": "input_text",
                                "text": "Summarize the main topics in this shareholder letter.",
                            },
                            {
                                "type": "input_file",
                                "file_url": "https://www.berkshirehathaway.com/letters/2024ltr.pdf",
                            },
                        ],
                    },
                ],
                reasoning={
                    "effort": "low",
                },
            )

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

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key=os.environ["COMETAPI_KEY"],
            )

            response = client.responses.create(
                model="gpt-6-astra",
                input="Search the web for the NASA Artemis II mission overview and cite the official NASA page.",
                tools=[
                    {
                        "type": "web_search",
                    },
                ],
                reasoning={
                    "effort": "low",
                },
            )

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

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key=os.environ["COMETAPI_KEY"],
            )

            stream = client.responses.create(
                model="gpt-6-astra",
                input="Tell me a three sentence bedtime story about a unicorn.",
                reasoning={
                    "effort": "low",
                },
                stream=True,
            )

            for event in stream:
                if event.type == "response.output_text.delta":
                    print(event.delta, end="")
        - lang: Python
          label: Functions
          source: |
            import os
            from openai import OpenAI

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key=os.environ["COMETAPI_KEY"],
            )

            response = client.responses.create(
                model="gpt-6-astra",
                input="What is the weather in Boston, MA, in celsius? Use the weather tool.",
                tools=[
                    {
                        "type": "function",
                        "name": "get_current_weather",
                        "description": "Get the current weather for a city.",
                        "parameters": {
                            "type": "object",
                            "properties": {
                                "location": {
                                    "type": "string",
                                    "description": "City and state, for example Boston, MA.",
                                },
                                "unit": {
                                    "type": "string",
                                    "enum": [
                                        "celsius",
                                        "fahrenheit",
                                    ],
                                    "description": "Temperature unit.",
                                },
                            },
                            "required": [
                                "location",
                                "unit",
                            ],
                            "additionalProperties": False,
                        },
                        "strict": True,
                    },
                ],
                tool_choice="auto",
                reasoning={
                    "effort": "low",
                },
            )

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

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key=os.environ["COMETAPI_KEY"],
            )

            response = client.responses.create(
                model="gpt-6-astra",
                input="Solve this step by step: what is 15% of 240?",
                reasoning={
                    "effort": "high",
                },
            )

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

            client = OpenAI(
                base_url="https://api.cometapi.com/v1",
                api_key=os.environ["COMETAPI_KEY"],
            )

            response = client.responses.create(
                model="gpt-6-astra",
                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",
                                                "description": "Programming language name.",
                                            },
                                            "use_case": {
                                                "type": "string",
                                                "description": "Main use case for the language.",
                                            },
                                        },
                                        "required": [
                                            "name",
                                            "use_case",
                                        ],
                                        "additionalProperties": False,
                                    },
                                    "description": "Three programming languages and their main uses.",
                                },
                            },
                            "required": [
                                "languages",
                            ],
                            "additionalProperties": False,
                        },
                    },
                },
                reasoning={
                    "effort": "low",
                },
            )

            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: process.env.COMETAPI_KEY,
            });

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

            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: process.env.COMETAPI_KEY,
            });

            const response = await client.responses.create({
                "model": "gpt-6-astra",
                "input": [
                    {
                        "role": "user",
                        "content": [
                            {
                                "type": "input_text",
                                "text": "Describe the road and surrounding landscape in this image."
                            },
                            {
                                "type": "input_image",
                                "image_url": "https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?w=1200"
                            }
                        ]
                    }
                ],
                "reasoning": {
                    "effort": "low"
                }
            });

            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: process.env.COMETAPI_KEY,
            });

            const response = await client.responses.create({
                "model": "gpt-6-astra",
                "input": [
                    {
                        "role": "user",
                        "content": [
                            {
                                "type": "input_text",
                                "text": "Summarize the main topics in this shareholder letter."
                            },
                            {
                                "type": "input_file",
                                "file_url": "https://www.berkshirehathaway.com/letters/2024ltr.pdf"
                            }
                        ]
                    }
                ],
                "reasoning": {
                    "effort": "low"
                }
            });

            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: process.env.COMETAPI_KEY,
            });

            const response = await client.responses.create({
                "model": "gpt-6-astra",
                "input": "Search the web for the NASA Artemis II mission overview and cite the official NASA page.",
                "tools": [
                    {
                        "type": "web_search"
                    }
                ],
                "reasoning": {
                    "effort": "low"
                }
            });

            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: process.env.COMETAPI_KEY,
            });

            const stream = await client.responses.create({
                "model": "gpt-6-astra",
                "input": "Tell me a three sentence bedtime story about a unicorn.",
                "reasoning": {
                    "effort": "low"
                },
                "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: process.env.COMETAPI_KEY,
            });

            const response = await client.responses.create({
                "model": "gpt-6-astra",
                "input": "What is the weather in Boston, MA, in celsius? Use the weather tool.",
                "tools": [
                    {
                        "type": "function",
                        "name": "get_current_weather",
                        "description": "Get the current weather for a city.",
                        "parameters": {
                            "type": "object",
                            "properties": {
                                "location": {
                                    "type": "string",
                                    "description": "City and state, for example Boston, MA."
                                },
                                "unit": {
                                    "type": "string",
                                    "enum": [
                                        "celsius",
                                        "fahrenheit"
                                    ],
                                    "description": "Temperature unit."
                                }
                            },
                            "required": [
                                "location",
                                "unit"
                            ],
                            "additionalProperties": false
                        },
                        "strict": true
                    }
                ],
                "tool_choice": "auto",
                "reasoning": {
                    "effort": "low"
                }
            });

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

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

            const response = await client.responses.create({
                "model": "gpt-6-astra",
                "input": "Solve this step by step: what is 15% of 240?",
                "reasoning": {
                    "effort": "high"
                }
            });

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

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

            const response = await client.responses.create({
                "model": "gpt-6-astra",
                "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",
                                                "description": "Programming language name."
                                            },
                                            "use_case": {
                                                "type": "string",
                                                "description": "Main use case for the language."
                                            }
                                        },
                                        "required": [
                                            "name",
                                            "use_case"
                                        ],
                                        "additionalProperties": false
                                    },
                                    "description": "Three programming languages and their main uses."
                                }
                            },
                            "required": [
                                "languages"
                            ],
                            "additionalProperties": false
                        }
                    }
                },
                "reasoning": {
                    "effort": "low"
                }
            });

            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-6-astra",
              "input": "Tell me a three sentence bedtime story about a unicorn.",
              "reasoning": {
                "effort": "low"
              }
            }'
        - 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-6-astra",
              "input": [
                {
                  "role": "user",
                  "content": [
                    {
                      "type": "input_text",
                      "text": "Describe the road and surrounding landscape in this image."
                    },
                    {
                      "type": "input_image",
                      "image_url": "https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?w=1200"
                    }
                  ]
                }
              ],
              "reasoning": {
                "effort": "low"
              }
            }'
        - 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-6-astra",
              "input": [
                {
                  "role": "user",
                  "content": [
                    {
                      "type": "input_text",
                      "text": "Summarize the main topics in this shareholder letter."
                    },
                    {
                      "type": "input_file",
                      "file_url": "https://www.berkshirehathaway.com/letters/2024ltr.pdf"
                    }
                  ]
                }
              ],
              "reasoning": {
                "effort": "low"
              }
            }'
        - 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-6-astra",
              "input": "Search the web for the NASA Artemis II mission overview and cite the official NASA page.",
              "tools": [
                {
                  "type": "web_search"
                }
              ],
              "reasoning": {
                "effort": "low"
              }
            }'
        - lang: Shell
          label: Streaming
          source: |
            curl https://api.cometapi.com/v1/responses \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              --no-buffer \
              -d '{
              "model": "gpt-6-astra",
              "input": "Tell me a three sentence bedtime story about a unicorn.",
              "reasoning": {
                "effort": "low"
              },
              "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-6-astra",
              "input": "What is the weather in Boston, MA, in celsius? Use the weather tool.",
              "tools": [
                {
                  "type": "function",
                  "name": "get_current_weather",
                  "description": "Get the current weather for a city.",
                  "parameters": {
                    "type": "object",
                    "properties": {
                      "location": {
                        "type": "string",
                        "description": "City and state, for example Boston, MA."
                      },
                      "unit": {
                        "type": "string",
                        "enum": [
                          "celsius",
                          "fahrenheit"
                        ],
                        "description": "Temperature unit."
                      }
                    },
                    "required": [
                      "location",
                      "unit"
                    ],
                    "additionalProperties": false
                  },
                  "strict": true
                }
              ],
              "tool_choice": "auto",
              "reasoning": {
                "effort": "low"
              }
            }'
        - lang: Shell
          label: Reasoning
          source: |
            curl https://api.cometapi.com/v1/responses \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -d '{
              "model": "gpt-6-astra",
              "input": "Solve this step by step: what is 15% of 240?",
              "reasoning": {
                "effort": "high"
              }
            }'
        - lang: Shell
          label: Structured Output
          source: |
            curl https://api.cometapi.com/v1/responses \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -d '{
              "model": "gpt-6-astra",
              "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",
                              "description": "Programming language name."
                            },
                            "use_case": {
                              "type": "string",
                              "description": "Main use case for the language."
                            }
                          },
                          "required": [
                            "name",
                            "use_case"
                          ],
                          "additionalProperties": false
                        },
                        "description": "Three programming languages and their main uses."
                      }
                    },
                    "required": [
                      "languages"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "reasoning": {
                "effort": "low"
              }
            }'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````