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

# Create a chat completion



## OpenAPI

````yaml POST /v1/chat/completions
openapi: 3.1.0
info:
  title: Antara API
  version: 1.0.0
  description: OpenAI- and Anthropic-compatible inference plus organization management.
servers:
  - url: https://api.antarah.dev
security: []
paths:
  /v1/chat/completions:
    post:
      summary: >-
        Create a chat completion (OpenAI Chat Completions); `stream: true`
        answers with server-sent events
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
      responses:
        '200':
          description: >-
            `application/json` when `stream` is false; otherwise
            `text/event-stream`: `data: <ChatCompletionChunk>` events, then
            `data: [DONE]`
          headers:
            x-request-id:
              schema:
                type: string
                description: Request ID (`req_…`); also sent as `request-id`
              required: false
              description: Request ID (`req_…`); also sent as `request-id`
            ratelimit-policy:
              schema:
                type: string
                description: e.g. `"rpm";q=60;w=60` (02 §8)
              required: false
              description: e.g. `"rpm";q=60;w=60` (02 §8)
            ratelimit:
              schema:
                type: string
                description: Scope closest to exhaustion, e.g. `"rpm";r=59;t=42`
              required: false
              description: Scope closest to exhaustion, e.g. `"rpm";r=59;t=42`
            x-ratelimit-limit-requests:
              schema:
                type: string
                description: RPM of the scope closest to exhaustion
              required: false
              description: RPM of the scope closest to exhaustion
            x-ratelimit-remaining-requests:
              schema:
                type: string
                description: Requests left in the window
              required: false
              description: Requests left in the window
            x-ratelimit-reset-requests:
              schema:
                type: string
                description: Duration, e.g. `"1s"`, `"6m0s"`
              required: false
              description: Duration, e.g. `"1s"`, `"6m0s"`
            x-ratelimit-limit-tokens:
              schema:
                type: string
                description: TPM of the scope closest to exhaustion
              required: false
              description: TPM of the scope closest to exhaustion
            x-ratelimit-remaining-tokens:
              schema:
                type: string
                description: Tokens left in the window
              required: false
              description: Tokens left in the window
            x-ratelimit-reset-tokens:
              schema:
                type: string
                description: Duration
              required: false
              description: Duration
            x-antara-policy-action:
              schema:
                type: string
                description: >-
                  `blocked` when an enforcing policy refused before the headers
                  were sent (02 §9.7)
              required: false
              description: >-
                `blocked` when an enforcing policy refused before the headers
                were sent (02 §9.7)
            deprecation:
              schema:
                type: string
                description: 'Deprecated model: `@<unix>` (RFC 9745)'
              required: false
              description: 'Deprecated model: `@<unix>` (RFC 9745)'
            sunset:
              schema:
                type: string
                description: 'Deprecated model: HTTP-date (RFC 8594)'
              required: false
              description: 'Deprecated model: HTTP-date (RFC 8594)'
            link:
              schema:
                type: string
                description: 'Deprecated model: `<docs>; rel="deprecation"`'
              required: false
              description: 'Deprecated model: `<docs>; rel="deprecation"`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletion'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/ChatCompletionStreamEvent'
        '400':
          description: '`context_length_exceeded`, `unknown_policy`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIError'
        '402':
          description: '`insufficient_credits`, `spend_limit_reached`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIError'
        '502':
          description: '`upstream_error`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIError'
        '503':
          description: '`upstream_unavailable`, `policy_evaluation_unavailable`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIError'
        '504':
          description: '`upstream_timeout`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIError'
        default:
          description: OpenAI-shaped error (02 §4.1)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIError'
      security:
        - projectKey: []
        - session: []
components:
  schemas:
    ChatCompletionRequest:
      type: object
      properties:
        model:
          type: string
          minLength: 1
          description: Public model ID, e.g. `a1` (A-05)
          example: a1
        messages:
          type: array
          items:
            oneOf:
              - type: object
                properties:
                  role:
                    type: string
                    enum:
                      - system
                  content:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - text
                            text:
                              type: string
                          required:
                            - type
                            - text
                        minItems: 1
                  name:
                    type: string
                required:
                  - role
                  - content
              - type: object
                properties:
                  role:
                    type: string
                    enum:
                      - developer
                  content:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - text
                            text:
                              type: string
                          required:
                            - type
                            - text
                        minItems: 1
                  name:
                    type: string
                required:
                  - role
                  - content
              - type: object
                properties:
                  role:
                    type: string
                    enum:
                      - user
                  content:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          oneOf:
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - text
                                text:
                                  type: string
                              required:
                                - type
                                - text
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - image_url
                                image_url:
                                  type: object
                                  properties:
                                    url:
                                      type: string
                                    detail:
                                      type: string
                                      enum:
                                        - auto
                                        - low
                                        - high
                                  required:
                                    - url
                              required:
                                - type
                                - image_url
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - input_audio
                              required:
                                - type
                              description: 'Rejected: `400 unsupported_modality`'
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - file
                              required:
                                - type
                              description: 'Rejected: `400 unsupported_modality`'
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - video_url
                              required:
                                - type
                              description: 'Rejected: `400 unsupported_modality`'
                        minItems: 1
                  name:
                    type: string
                required:
                  - role
                  - content
              - type: object
                properties:
                  role:
                    type: string
                    enum:
                      - assistant
                  content:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          oneOf:
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - text
                                text:
                                  type: string
                              required:
                                - type
                                - text
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - refusal
                                refusal:
                                  type: string
                              required:
                                - type
                                - refusal
                      - type: 'null'
                  refusal:
                    type:
                      - string
                      - 'null'
                  name:
                    type: string
                  tool_calls:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        type:
                          type: string
                          enum:
                            - function
                        function:
                          type: object
                          properties:
                            name:
                              type: string
                            arguments:
                              type: string
                          required:
                            - name
                            - arguments
                      required:
                        - id
                        - type
                        - function
                  reasoning_content:
                    type:
                      - string
                      - 'null'
                required:
                  - role
              - type: object
                properties:
                  role:
                    type: string
                    enum:
                      - tool
                  content:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - text
                            text:
                              type: string
                          required:
                            - type
                            - text
                        minItems: 1
                  tool_call_id:
                    type: string
                required:
                  - role
                  - content
                  - tool_call_id
          minItems: 1
          maxItems: 10000
        max_tokens:
          type:
            - integer
            - 'null'
          minimum: 1
          description: 1…the model's `max_output_tokens`
        max_completion_tokens:
          type:
            - integer
            - 'null'
          minimum: 1
          description: 1…the model's `max_output_tokens`
        temperature:
          type:
            - number
            - 'null'
          minimum: 0
          maximum: 2
        top_p:
          type:
            - number
            - 'null'
          minimum: 0
          maximum: 1
        frequency_penalty:
          type:
            - number
            - 'null'
          minimum: -2
          maximum: 2
        presence_penalty:
          type:
            - number
            - 'null'
          minimum: -2
          maximum: 2
        stop:
          anyOf:
            - type: string
            - type: array
              items:
                type: string
              maxItems: 4
            - type: 'null'
        seed:
          type:
            - integer
            - 'null'
        logit_bias:
          type:
            - object
            - 'null'
          additionalProperties:
            type: number
            minimum: -100
            maximum: 100
        tools:
          type:
            - array
            - 'null'
          items:
            type: object
            properties:
              type:
                type: string
                enum:
                  - function
              function:
                type: object
                properties:
                  name:
                    type: string
                    minLength: 1
                  description:
                    type: string
                  parameters:
                    type: object
                    additionalProperties: {}
                  strict:
                    type:
                      - boolean
                      - 'null'
                required:
                  - name
            required:
              - type
              - function
          maxItems: 128
        tool_choice:
          anyOf:
            - type: string
              enum:
                - none
                - auto
                - required
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - function
                function:
                  type: object
                  properties:
                    name:
                      type: string
                  required:
                    - name
              required:
                - type
                - function
            - type: 'null'
        parallel_tool_calls:
          type:
            - boolean
            - 'null'
        response_format:
          oneOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - text
              required:
                - type
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - json_object
              required:
                - type
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - json_schema
                json_schema:
                  type: object
                  properties:
                    name:
                      type: string
                      minLength: 1
                    description:
                      type: string
                    schema:
                      type: object
                      additionalProperties: {}
                    strict:
                      type:
                        - boolean
                        - 'null'
                  required:
                    - name
              required:
                - type
                - json_schema
            - type: 'null'
        reasoning_effort:
          type:
            - string
            - 'null'
          enum:
            - none
            - minimal
            - low
            - medium
            - high
            - xhigh
            - max
            - null
          description: Must be one of the model's `reasoning_efforts`
        prompt_cache_key:
          type:
            - string
            - 'null'
          minLength: 0
          maxLength: 512
        logprobs:
          type:
            - boolean
            - 'null'
        top_logprobs:
          type:
            - integer
            - 'null'
          minimum: 0
          maximum: 20
        'n':
          type:
            - integer
            - 'null'
          description: Only `1`
        modalities:
          type:
            - array
            - 'null'
          items:
            type: string
          description: Only `["text"]`
        stream:
          type:
            - boolean
            - 'null'
          description: Default `false`
        stream_options:
          type:
            - object
            - 'null'
          properties:
            include_usage:
              type: boolean
          description: >-
            Usage is always metered; the final usage chunk is sent only when
            `include_usage` is true
        reasoning:
          type:
            - object
            - 'null'
          properties:
            effort:
              type: string
              enum:
                - none
                - minimal
                - low
                - medium
                - high
                - xhigh
                - max
            max_tokens:
              type: integer
              minimum: 0
            exclude:
              type: boolean
            enabled:
              type: boolean
          description: OpenRouter-style; mapped to `reasoning_effort`
        thinking:
          anyOf:
            - type: boolean
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - enabled
                    - disabled
              required:
                - type
            - type: 'null'
          description: Mapped to `reasoning_effort`
        include_reasoning:
          type:
            - boolean
            - 'null'
          description: '`false` strips `reasoning_content` from the output'
        policy_ids:
          type:
            - array
            - 'null'
          items:
            type: string
            minLength: 1
            maxLength: 120
          maxItems: 20
          description: 'Antara extension: published policies to add for this request'
        user:
          type:
            - string
            - 'null'
          minLength: 0
          maxLength: 512
        safety_identifier:
          type:
            - string
            - 'null'
          minLength: 0
          maxLength: 64
        store:
          type:
            - boolean
            - 'null'
        metadata:
          type:
            - object
            - 'null'
          additionalProperties:
            type: string
        service_tier:
          type:
            - string
            - 'null'
        structuredOutputs:
          type:
            - boolean
            - 'null'
        prompt_cache_retention:
          type:
            - string
            - 'null'
      required:
        - model
        - messages
      additionalProperties: false
      description: >-
        Rejected with `400 unsupported_parameter`: `n` ≠ 1, `audio`,
        `modalities` other than `["text"]`, `prediction`, `web_search_options`,
        `functions`, `function_call`, `prompt_logprobs`, `cache_salt`, and any
        field not listed here.
    ChatCompletion:
      type: object
      properties:
        id:
          type: string
          pattern: ^chatcmpl_[0-9a-f]{32}$
          example: chatcmpl_0193a6c2e7b47c3d9f1e2a4b5c6d7e8f
        object:
          type: string
          enum:
            - chat.completion
        created:
          type: integer
          description: Unix seconds
          example: 1793750400
        model:
          type: string
          example: a1
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              message:
                type: object
                properties:
                  role:
                    type: string
                    enum:
                      - assistant
                  content:
                    type:
                      - string
                      - 'null'
                    description: >-
                      On a policy refusal, the refusal text (also in `refusal`)
                      (02 §9.7)
                  refusal:
                    type:
                      - string
                      - 'null'
                  reasoning_content:
                    type:
                      - string
                      - 'null'
                    description: 'Reasoning text; omitted when `include_reasoning: false`'
                  tool_calls:
                    type:
                      - array
                      - 'null'
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        type:
                          type: string
                          enum:
                            - function
                        function:
                          type: object
                          properties:
                            name:
                              type: string
                            arguments:
                              type: string
                          required:
                            - name
                            - arguments
                      required:
                        - id
                        - type
                        - function
                required:
                  - role
                  - content
                  - refusal
                  - tool_calls
              finish_reason:
                type: string
                enum:
                  - stop
                  - length
                  - tool_calls
                  - content_filter
              logprobs:
                type:
                  - object
                  - 'null'
                properties:
                  content:
                    type:
                      - array
                      - 'null'
                    items:
                      type: object
                      properties:
                        token:
                          type: string
                        logprob:
                          type: number
                        bytes:
                          type:
                            - array
                            - 'null'
                          items:
                            type: integer
                        top_logprobs:
                          type: array
                          items:
                            type: object
                            properties:
                              token:
                                type: string
                              logprob:
                                type: number
                              bytes:
                                type:
                                  - array
                                  - 'null'
                                items:
                                  type: integer
                            required:
                              - token
                              - logprob
                              - bytes
                      required:
                        - token
                        - logprob
                        - bytes
                        - top_logprobs
                  refusal:
                    type:
                      - array
                      - 'null'
                    items:
                      type: object
                      properties:
                        token:
                          type: string
                        logprob:
                          type: number
                        bytes:
                          type:
                            - array
                            - 'null'
                          items:
                            type: integer
                        top_logprobs:
                          type: array
                          items:
                            type: object
                            properties:
                              token:
                                type: string
                              logprob:
                                type: number
                              bytes:
                                type:
                                  - array
                                  - 'null'
                                items:
                                  type: integer
                            required:
                              - token
                              - logprob
                              - bytes
                      required:
                        - token
                        - logprob
                        - bytes
                        - top_logprobs
                required:
                  - content
                  - refusal
            required:
              - index
              - message
              - finish_reason
              - logprobs
        usage:
          $ref: '#/components/schemas/ChatCompletionUsage'
        system_fingerprint:
          type: 'null'
      required:
        - id
        - object
        - created
        - model
        - choices
        - usage
        - system_fingerprint
    ChatCompletionStreamEvent:
      anyOf:
        - $ref: '#/components/schemas/ChatCompletionChunk'
        - $ref: '#/components/schemas/OpenAIError'
    OpenAIError:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
              example: invalid_request_error
            param:
              type:
                - string
                - 'null'
            code:
              type: string
              example: invalid_api_key
            request_id:
              type: string
          required:
            - message
            - type
            - param
            - code
            - request_id
      required:
        - error
    ChatCompletionUsage:
      type: object
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
        prompt_tokens_details:
          type: object
          properties:
            cached_tokens:
              type: integer
          required:
            - cached_tokens
        completion_tokens_details:
          type: object
          properties:
            reasoning_tokens:
              type: integer
          required:
            - reasoning_tokens
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
        - prompt_tokens_details
        - completion_tokens_details
    ChatCompletionChunk:
      type: object
      properties:
        id:
          type: string
          pattern: ^chatcmpl_[0-9a-f]{32}$
          example: chatcmpl_0193a6c2e7b47c3d9f1e2a4b5c6d7e8f
        object:
          type: string
          enum:
            - chat.completion.chunk
        created:
          type: integer
          description: Unix seconds
          example: 1793750400
        model:
          type: string
          example: a1
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              delta:
                type: object
                properties:
                  role:
                    type: string
                    enum:
                      - assistant
                  content:
                    type:
                      - string
                      - 'null'
                  reasoning_content:
                    type: string
                  refusal:
                    type:
                      - string
                      - 'null'
                  tool_calls:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                        id:
                          type: string
                        type:
                          type: string
                          enum:
                            - function
                        function:
                          type: object
                          properties:
                            name:
                              type: string
                            arguments:
                              type: string
                      required:
                        - index
              finish_reason:
                type:
                  - string
                  - 'null'
                enum:
                  - stop
                  - length
                  - tool_calls
                  - content_filter
                  - null
              logprobs:
                type:
                  - object
                  - 'null'
                properties:
                  content:
                    type:
                      - array
                      - 'null'
                    items:
                      type: object
                      properties:
                        token:
                          type: string
                        logprob:
                          type: number
                        bytes:
                          type:
                            - array
                            - 'null'
                          items:
                            type: integer
                        top_logprobs:
                          type: array
                          items:
                            type: object
                            properties:
                              token:
                                type: string
                              logprob:
                                type: number
                              bytes:
                                type:
                                  - array
                                  - 'null'
                                items:
                                  type: integer
                            required:
                              - token
                              - logprob
                              - bytes
                      required:
                        - token
                        - logprob
                        - bytes
                        - top_logprobs
                  refusal:
                    type:
                      - array
                      - 'null'
                    items:
                      type: object
                      properties:
                        token:
                          type: string
                        logprob:
                          type: number
                        bytes:
                          type:
                            - array
                            - 'null'
                          items:
                            type: integer
                        top_logprobs:
                          type: array
                          items:
                            type: object
                            properties:
                              token:
                                type: string
                              logprob:
                                type: number
                              bytes:
                                type:
                                  - array
                                  - 'null'
                                items:
                                  type: integer
                            required:
                              - token
                              - logprob
                              - bytes
                      required:
                        - token
                        - logprob
                        - bytes
                        - top_logprobs
                required:
                  - content
                  - refusal
            required:
              - index
              - delta
              - finish_reason
              - logprobs
        usage:
          allOf:
            - $ref: '#/components/schemas/ChatCompletionUsage'
            - type:
                - object
                - 'null'
              description: >-
                Set only on the final chunk (`choices: []`), which is sent only
                with `stream_options.include_usage: true`
        system_fingerprint:
          type: 'null'
      required:
        - id
        - object
        - created
        - model
        - choices
        - usage
        - system_fingerprint
  securitySchemes:
    projectKey:
      type: http
      scheme: bearer
      description: '`ak_…` project API key (or `x-api-key`)'
    session:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Supabase access token + `Antara-Organization` (management) or
        `Antara-Project` (inference)

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.