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

# Messages

> Anthropic Messages–compatible endpoint on the Modellix LLM gateway. Accepts a synchronous request with `model` (provider/name format, typically `anthropic/...`), Anthropic-style `messages`, and required `max_tokens`; optional `system` prompt is supported. Returns a Messages JSON object by default, or SSE (`text/event-stream`) when `stream=true`. Auth accepts `Authorization: Bearer` or `x-api-key` (same Modellix API Key). Use this path for the Anthropic SDK, Claude Code, and other Anthropic-native clients; optional `anthropic-version` header is forwarded when present. Do not send OpenAI Chat Completions or Responses field shapes on this endpoint—use `/chat/completions` or `/responses` instead. Optional fields follow [Anthropic Messages](https://docs.anthropic.com/en/api/messages); support depends on the selected model.



## OpenAPI

````yaml /llm/llm.json post /messages
openapi: 3.1.0
info:
  title: Modellix LLM API
  description: >-
    Public API of the Modellix LLM Gateway (llm-bff): OpenAI-compatible Chat
    Completions and Responses, plus Anthropic-compatible Messages.


    Optional fields follow the corresponding official protocols; this document
    lists commonly used core fields only. See `docs/api/llm.md` for the
    human-readable guide.
  version: '2026-08-04'
  contact:
    name: Modellix
servers:
  - url: https://llm.modellix.ai/v1
    description: Production
security:
  - BearerAuth: []
  - ApiKeyAuth: []
tags:
  - name: Chat Completions
    description: OpenAI-compatible Chat Completions
  - name: Responses
    description: OpenAI-compatible Responses
  - name: Messages
    description: Anthropic-compatible Messages
paths:
  /messages:
    post:
      tags:
        - Messages
      summary: Messages
      description: >-
        Anthropic Messages–compatible endpoint on the Modellix LLM gateway.
        Accepts a synchronous request with `model` (provider/name format,
        typically `anthropic/...`), Anthropic-style `messages`, and required
        `max_tokens`; optional `system` prompt is supported. Returns a Messages
        JSON object by default, or SSE (`text/event-stream`) when `stream=true`.
        Auth accepts `Authorization: Bearer` or `x-api-key` (same Modellix API
        Key). Use this path for the Anthropic SDK, Claude Code, and other
        Anthropic-native clients; optional `anthropic-version` header is
        forwarded when present. Do not send OpenAI Chat Completions or Responses
        field shapes on this endpoint—use `/chat/completions` or `/responses`
        instead. Optional fields follow [Anthropic
        Messages](https://docs.anthropic.com/en/api/messages); support depends
        on the selected model.
      operationId: createMessage
      parameters:
        - $ref: '#/components/parameters/SessionIdHeader'
        - name: anthropic-version
          in: header
          required: false
          description: >-
            Anthropic API version header (optional; often set automatically by
            native Anthropic clients; forwarded upstream when present)
          schema:
            type: string
            example: '2023-06-01'
      requestBody:
        required: true
        description: >-
          Anthropic Messages request body. Requires model, messages, and
          max_tokens; optional system and stream. Message roles are user or
          assistant only.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MessagesRequest'
            example:
              model: anthropic/claude-sonnet-5
              max_tokens: 256
              messages:
                - role: user
                  content: ping
      responses:
        '200':
          description: Success. Non-streaming returns JSON; streaming returns SSE.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessagesResponse'
            text/event-stream:
              schema:
                type: string
                description: 'SSE: Anthropic Messages event stream'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        5XX:
          $ref: '#/components/responses/UpstreamError'
components:
  parameters:
    SessionIdHeader:
      name: X-Mdlx-Session-Id
      in: header
      required: false
      description: >-
        Optional session affinity header. Length 8–128; alphanumeric, `-`, and
        `_` only.
      schema:
        type: string
        minLength: 8
        maxLength: 128
        pattern: ^[A-Za-z0-9_-]+$
        example: my-conversation-001
  schemas:
    MessagesRequest:
      type: object
      required:
        - model
        - messages
        - max_tokens
      additionalProperties: true
      description: Core fields below; other fields follow Anthropic Messages.
      properties:
        model:
          $ref: '#/components/schemas/ModelId'
        messages:
          type: array
          minItems: 1
          description: >-
            Anthropic Messages list (min 1). Roles are user or assistant only;
            put system text in system, not as a message role.
          items:
            type: object
            required:
              - role
              - content
            additionalProperties: true
            description: A single Anthropic Messages turn with role and content.
            properties:
              role:
                type: string
                enum:
                  - user
                  - assistant
                description: >-
                  Anthropic message role. Only user or assistant; system belongs
                  in the system field.
              content:
                description: Text string or content-block array
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: object
                      additionalProperties: true
                      description: Anthropic Messages content block
        max_tokens:
          type: integer
          minimum: 1
          description: Required. Maximum number of tokens to generate.
        stream:
          type: boolean
          default: false
          description: >-
            Default false. When true, returns an Anthropic Messages SSE event
            stream.
        system:
          description: System prompt (string or content-block array)
          oneOf:
            - type: string
            - type: array
              items:
                type: object
                additionalProperties: true
                description: Anthropic system content block
    MessagesResponse:
      type: object
      additionalProperties: true
      description: Shape follows Anthropic message
      properties:
        id:
          type: string
          description: Unique identifier for this Anthropic message.
        type:
          type: string
          example: message
          description: Object type. Typically message for Anthropic Messages.
        role:
          type: string
          example: assistant
          description: Role of the response message. Typically assistant.
        model:
          type: string
          description: Model ID that produced this Anthropic message.
        content:
          type: array
          description: Array of Anthropic content blocks in the assistant reply.
          items:
            type: object
            additionalProperties: true
            description: A single Anthropic Messages content block in the response.
        stop_reason:
          type:
            - string
            - 'null'
          description: Why generation stopped, or null.
        usage:
          type: object
          additionalProperties: true
          description: >-
            Token usage object for the Anthropic Messages API. Shape follows
            Anthropic usage (for example input and output tokens), not Chat
            Completions prompt_tokens fields.
    ModelId:
      type: string
      description: Model ID in `provider/name` form
      examples:
        - openai/gpt-5.5
        - openai/gpt-5.6-sol
        - anthropic/claude-sonnet-5
        - google/gemini-3.6-flash
    ErrorBody:
      type: object
      required:
        - error
      description: >-
        Gateway error envelope shared by Chat Completions, Responses, and
        Messages.
      properties:
        error:
          type: object
          required:
            - message
            - type
          additionalProperties: true
          description: Error details object.
          properties:
            message:
              type: string
              description: Human-readable error message.
            type:
              type: string
              description: >-
                Error type string (for example invalid_request_error,
                rate_limit_exceeded, insufficient_quota).
              examples:
                - invalid_request_error
                - api_error
                - rate_limit_exceeded
                - request_limited
                - insufficient_quota
            code:
              type:
                - string
                - 'null'
              description: Optional machine-readable error code, or null.
            param:
              type:
                - string
                - 'null'
              description: Optional parameter name related to the error, or null.
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
    Unauthorized:
      description: >-
        Missing or invalid API key, or conflicting Authorization and x-api-key
        values
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          example:
            error:
              message: invalid API key
              type: invalid_request_error
    PaymentRequired:
      description: Insufficient account balance
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          example:
            error:
              message: insufficient balance, please recharge your account
              type: insufficient_quota
    NotFound:
      description: Unknown path, or the selected model is unavailable
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          examples:
            modelUnavailable:
              summary: Model unavailable
              value:
                error:
                  message: the selected model is unavailable
                  type: invalid_request_error
    RateLimited:
      description: >-
        Rate limited (RPM or other request limits), or the selected model is
        temporarily unavailable (e.g. upstream deployment cooldown)
      headers:
        X-RateLimit-Limit:
          description: Maximum number of requests allowed in the current rate-limit window.
          schema:
            type: integer
        X-RateLimit-Remaining:
          description: Number of requests remaining in the current rate-limit window.
          schema:
            type: integer
        X-RateLimit-Reset:
          description: Unix timestamp (seconds) when the current rate-limit window resets.
          schema:
            type: integer
        Retry-After:
          schema:
            type: integer
          description: >-
            May be returned when the model is temporarily unavailable; value in
            seconds
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          examples:
            rpm:
              summary: RPM exceeded
              value:
                error:
                  message: rate limit exceeded
                  type: rate_limit_exceeded
            modelCooldown:
              summary: Model temporarily unavailable
              value:
                error:
                  message: >-
                    the selected model is temporarily unavailable, please retry
                    later or try another model
                  type: api_error
    UpstreamError:
      description: >-
        Temporary service unavailability or upstream error (client-facing
        message may be sanitized)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        Authorization: Bearer <Modellix API Key> (OpenAI SDK, Codex, OpenCode,
        etc.)
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        x-api-key: <Modellix API Key> (Anthropic SDK, Claude Code, etc.).
        Equivalent to Bearer; if both are present they must be the same key.

````