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



## OpenAPI

````yaml POST /v1/messages
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/messages:
    post:
      summary: >-
        Create a message (Anthropic Messages, translated to the upstream's Chat
        Completions); `stream: true` answers with server-sent events
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MessageRequest'
      responses:
        '200':
          description: >-
            `application/json` when `stream` is false; otherwise
            `text/event-stream`: `event: <type>` + `data: <MessageStreamEvent>`,
            ending with `message_stop`
          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/Message'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/MessageStreamEvent'
        '400':
          description: '`context_length_exceeded`, `unknown_policy`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicError'
        '402':
          description: '`insufficient_credits`, `spend_limit_reached`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicError'
        '502':
          description: '`upstream_error`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicError'
        '503':
          description: '`upstream_unavailable`, `policy_evaluation_unavailable`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicError'
        '504':
          description: '`upstream_timeout`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicError'
        default:
          description: Anthropic-shaped error (02 §4.1)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicError'
      security:
        - projectKey: []
        - session: []
components:
  schemas:
    MessageRequest:
      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:
                      - user
                  content:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          oneOf:
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - text
                                text:
                                  type: string
                                  minLength: 1
                              required:
                                - type
                                - text
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - image
                                source:
                                  oneOf:
                                    - type: object
                                      properties:
                                        type:
                                          type: string
                                          enum:
                                            - base64
                                        media_type:
                                          type: string
                                          enum:
                                            - image/png
                                            - image/jpeg
                                            - image/webp
                                            - image/gif
                                        data:
                                          type: string
                                      required:
                                        - type
                                        - media_type
                                        - data
                                    - type: object
                                      properties:
                                        type:
                                          type: string
                                          enum:
                                            - url
                                        url:
                                          type: string
                                      required:
                                        - type
                                        - url
                              required:
                                - type
                                - source
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - tool_result
                                tool_use_id:
                                  type: string
                                  minLength: 1
                                content:
                                  anyOf:
                                    - type: string
                                    - type: array
                                      items:
                                        oneOf:
                                          - type: object
                                            properties:
                                              type:
                                                type: string
                                                enum:
                                                  - text
                                              text:
                                                type: string
                                                minLength: 1
                                            required:
                                              - type
                                              - text
                                          - type: object
                                            properties:
                                              type:
                                                type: string
                                                enum:
                                                  - image
                                              source:
                                                oneOf:
                                                  - type: object
                                                    properties:
                                                      type:
                                                        type: string
                                                        enum:
                                                          - base64
                                                      media_type:
                                                        type: string
                                                        enum:
                                                          - image/png
                                                          - image/jpeg
                                                          - image/webp
                                                          - image/gif
                                                      data:
                                                        type: string
                                                    required:
                                                      - type
                                                      - media_type
                                                      - data
                                                  - type: object
                                                    properties:
                                                      type:
                                                        type: string
                                                        enum:
                                                          - url
                                                      url:
                                                        type: string
                                                    required:
                                                      - type
                                                      - url
                                            required:
                                              - type
                                              - source
                                is_error:
                                  type: boolean
                              required:
                                - type
                                - tool_use_id
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - document
                              required:
                                - type
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - search_result
                              required:
                                - type
                        minItems: 1
                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
                                  minLength: 1
                              required:
                                - type
                                - text
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - tool_use
                                id:
                                  type: string
                                  minLength: 1
                                name:
                                  type: string
                                  minLength: 1
                                input:
                                  type: object
                                  additionalProperties: {}
                              required:
                                - type
                                - id
                                - name
                                - input
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - thinking
                                thinking:
                                  type: string
                                signature:
                                  type: string
                              required:
                                - type
                                - thinking
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - redacted_thinking
                                data:
                                  type: string
                              required:
                                - type
                                - data
                required:
                  - role
                  - content
          minItems: 1
          maxItems: 10000
        system:
          anyOf:
            - type: string
            - type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                    enum:
                      - text
                  text:
                    type: string
                    minLength: 1
                required:
                  - type
                  - text
        tools:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
              name:
                type: string
                minLength: 1
              description:
                type: string
              input_schema:
                type: object
                additionalProperties: {}
            required:
              - name
          maxItems: 128
        max_tokens:
          type: integer
          minimum: 1
          description: Required. 1…the model's `max_output_tokens`
        temperature:
          type: number
          minimum: 0
          maximum: 1
          description: 0–1 (Anthropic's range)
        top_p:
          type: number
          minimum: 0
          maximum: 1
        stop_sequences:
          type: array
          items:
            type: string
          maxItems: 4
        tool_choice:
          oneOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - auto
                disable_parallel_tool_use:
                  type: boolean
              required:
                - type
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - any
                disable_parallel_tool_use:
                  type: boolean
              required:
                - type
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - none
              required:
                - type
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - tool
                name:
                  type: string
                  minLength: 1
                disable_parallel_tool_use:
                  type: boolean
              required:
                - type
                - name
        thinking:
          anyOf:
            - type: boolean
              enum:
                - false
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - enabled
                budget_tokens:
                  type: integer
                  minimum: 1
              required:
                - type
                - budget_tokens
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - disabled
              required:
                - type
          description: >-
            `budget_tokens` maps to a reasoning effort; `output_config.effort`
            wins
        output_config:
          type: object
          properties:
            effort:
              type: string
              enum:
                - none
                - minimal
                - low
                - medium
                - high
                - xhigh
                - max
            format:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - json_schema
                schema:
                  type: object
                  additionalProperties: {}
              required:
                - type
                - schema
              description: >-
                Structured output → Chat `response_format: {type:"json_schema",
                json_schema:{name:"output", schema, strict:true}}`
        top_k:
          type: integer
          description: 'Rejected: `400 unsupported_parameter`'
        stream:
          type: boolean
          description: Default `false`
        include_reasoning:
          type: boolean
          description: '`false` drops `thinking` blocks 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'
        metadata:
          type: object
          properties:
            user_id:
              type:
                - string
                - 'null'
        service_tier:
          type: string
        context_management: {}
      required:
        - model
        - messages
        - max_tokens
      additionalProperties: false
      description: >-
        Rejected with `400 unsupported_parameter`: `top_k`, server tools,
        `document` blocks, `container`, `mcp_servers`, and any field not listed
        here.
    Message:
      type: object
      properties:
        id:
          type: string
          pattern: ^msg_[0-9a-f]{32}$
          example: msg_0193a6c2e7b47c3d9f1e2a4b5c6d7e8f
        type:
          type: string
          enum:
            - message
        role:
          type: string
          enum:
            - assistant
        model:
          type: string
          example: a1
        content:
          type: array
          items:
            oneOf:
              - type: object
                properties:
                  type:
                    type: string
                    enum:
                      - thinking
                  thinking:
                    type: string
                  signature:
                    type: string
                    enum:
                      - ''
                required:
                  - type
                  - thinking
                  - signature
              - type: object
                properties:
                  type:
                    type: string
                    enum:
                      - text
                  text:
                    type: string
                required:
                  - type
                  - text
              - type: object
                properties:
                  type:
                    type: string
                    enum:
                      - tool_use
                  id:
                    type: string
                  name:
                    type: string
                  input:
                    type: object
                    additionalProperties: {}
                required:
                  - type
                  - id
                  - name
                  - input
        stop_reason:
          type:
            - string
            - 'null'
          enum:
            - end_turn
            - max_tokens
            - stop_sequence
            - tool_use
            - refusal
            - null
        stop_sequence:
          type:
            - string
            - 'null'
        usage:
          $ref: '#/components/schemas/MessageUsage'
      required:
        - id
        - type
        - role
        - model
        - content
        - stop_reason
        - stop_sequence
        - usage
    MessageStreamEvent:
      oneOf:
        - type: object
          properties:
            type:
              type: string
              enum:
                - message_start
            message:
              allOf:
                - $ref: '#/components/schemas/Message'
                - type: object
                  properties:
                    content:
                      type: array
                      items: {}
                      maxItems: 0
                    stop_reason:
                      type: 'null'
          required:
            - type
            - message
        - type: object
          properties:
            type:
              type: string
              enum:
                - content_block_start
            index:
              type: integer
            content_block:
              oneOf:
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - thinking
                    thinking:
                      type: string
                      enum:
                        - ''
                    signature:
                      type: string
                      enum:
                        - ''
                  required:
                    - type
                    - thinking
                    - signature
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - text
                    text:
                      type: string
                      enum:
                        - ''
                  required:
                    - type
                    - text
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - tool_use
                    id:
                      type: string
                    name:
                      type: string
                    input:
                      type: object
                      properties: {}
                  required:
                    - type
                    - id
                    - name
                    - input
          required:
            - type
            - index
            - content_block
        - type: object
          properties:
            type:
              type: string
              enum:
                - content_block_delta
            index:
              type: integer
            delta:
              oneOf:
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - thinking_delta
                    thinking:
                      type: string
                  required:
                    - type
                    - thinking
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - text_delta
                    text:
                      type: string
                  required:
                    - type
                    - text
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - input_json_delta
                    partial_json:
                      type: string
                  required:
                    - type
                    - partial_json
          required:
            - type
            - index
            - delta
        - type: object
          properties:
            type:
              type: string
              enum:
                - content_block_stop
            index:
              type: integer
          required:
            - type
            - index
        - type: object
          properties:
            type:
              type: string
              enum:
                - message_delta
            delta:
              type: object
              properties:
                stop_reason:
                  type:
                    - string
                    - 'null'
                  enum:
                    - end_turn
                    - max_tokens
                    - stop_sequence
                    - tool_use
                    - refusal
                    - null
                stop_sequence:
                  type:
                    - string
                    - 'null'
              required:
                - stop_reason
                - stop_sequence
            usage:
              $ref: '#/components/schemas/MessageUsage'
          required:
            - type
            - delta
            - usage
        - type: object
          properties:
            type:
              type: string
              enum:
                - message_stop
          required:
            - type
        - type: object
          properties:
            type:
              type: string
              enum:
                - ping
          required:
            - type
        - type: object
          properties:
            type:
              type: string
              enum:
                - error
            error:
              type: object
              properties:
                type:
                  type: string
                  example: invalid_request_error
                message:
                  type: string
                code:
                  type: string
              required:
                - type
                - message
                - code
            request_id:
              type: string
          required:
            - type
            - error
    AnthropicError:
      type: object
      properties:
        type:
          type: string
          enum:
            - error
        error:
          type: object
          properties:
            type:
              type: string
              example: invalid_request_error
            message:
              type: string
            code:
              type: string
          required:
            - type
            - message
            - code
        request_id:
          type: string
      required:
        - type
        - error
        - request_id
    MessageUsage:
      type: object
      properties:
        input_tokens:
          type: integer
          description: Excludes cache reads (Anthropic's convention)
        output_tokens:
          type: integer
        cache_read_input_tokens:
          type: integer
      required:
        - input_tokens
        - output_tokens
        - cache_read_input_tokens
  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.