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

# Create a message

> Generate an Anthropic-compatible message response from Messages API input. Supports streaming, tool use, and multimodal content blocks.



## OpenAPI

````yaml /openapi/naga-api.json post /v1/messages
openapi: 3.1.0
info:
  title: NagaAI API
  summary: Unified AI API with OpenAI and Anthropic compatibility layers.
  version: '2026-03-31'
  contact:
    name: NagaAI
    url: https://naga.ac
  termsOfService: https://naga.ac/legal/terms
servers:
  - url: https://api.naga.ac
    description: Production
  - url: http://localhost:8500
    description: Local development
security: []
tags:
  - name: Chat Completions
    description: >-
      OpenAI-compatible chat completion requests, including streaming, tools,
      and multimodal input.
  - name: Messages
    description: >-
      Anthropic-compatible Messages API requests used by Claude-style clients
      and agents.
  - name: Responses
    description: >-
      OpenAI-compatible Responses API requests for structured input, tools, and
      streaming output items.
  - name: Embeddings
    description: >-
      Create vector embeddings for search, retrieval, clustering, and ranking
      use cases.
  - name: Images
    description: >-
      Generate or edit images with multimodal models and OpenAI-compatible
      payloads.
  - name: Audio
    description: >-
      Generate speech or convert uploaded audio into transcriptions and
      translations.
  - name: Moderations
    description: Classify text and image inputs for safety policy categories.
  - name: Models
    description: List available models, capabilities, and pricing metadata.
  - name: Startups
    description: >-
      Public metadata about AI startups and model providers surfaced by the
      gateway.
  - name: Account
    description: Provisioning-key protected account balance and usage endpoints.
  - name: API Keys
    description: Provisioning-key protected API key management endpoints.
paths:
  /v1/messages:
    post:
      tags:
        - Messages
      summary: Create a message
      description: >-
        Generate an Anthropic-compatible message response from Messages API
        input. Supports streaming, tool use, and multimodal content blocks.
      operationId: createMessage
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MessagesRequest'
            examples:
              basic:
                summary: Basic Anthropic request
                value:
                  model: claude-sonnet-4.5
                  max_tokens: 512
                  messages:
                    - role: user
                      content: Explain the CAP theorem in one paragraph.
              tool_use:
                summary: Tool-enabled request
                value:
                  model: claude-sonnet-4.5
                  max_tokens: 1024
                  messages:
                    - role: user
                      content: Find the weather in Amsterdam and tell me what to wear.
                  tools:
                    - name: get_weather
                      description: Look up live weather for a city.
                      input_schema:
                        type: object
                        properties:
                          city:
                            type: string
                        required:
                          - city
                  tool_choice:
                    type: auto
                    disable_parallel_tool_use: false
        required: true
      responses:
        '200':
          description: >-
            JSON response when stream=false, or Anthropic-style Server-Sent
            Events when stream=true.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnthropicMessageResponse'
            text/event-stream:
              schema:
                type: string
                description: >-
                  Anthropic-style event stream. Each event payload contains JSON
                  for a message stream event.
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '402':
          description: Insufficient credits
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '410':
          description: Model deprecated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationErrorResponse'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '503':
          description: Upstream service error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
      security:
        - bearerAuth: []
        - xApiKeyAuth: []
components:
  schemas:
    MessagesRequest:
      properties:
        model:
          type: string
          title: Model
          description: Model identifier to route the request to.
          examples:
            - claude-sonnet-4.5
        max_tokens:
          type: integer
          minimum: 1
          title: Max Tokens
          description: Maximum number of output tokens to generate.
        messages:
          items:
            $ref: '#/components/schemas/MessageParam'
          type: array
          maxItems: 100000
          minItems: 1
          title: Messages
          description: Conversation history in Anthropic Messages format.
        system:
          anyOf:
            - type: string
            - items:
                $ref: '#/components/schemas/TextBlockParam'
              type: array
            - type: 'null'
          title: System
        stream:
          type: boolean
          title: Stream
          description: Return Anthropic-style SSE events instead of a single JSON response.
          default: false
        temperature:
          anyOf:
            - type: number
              maximum: 2
              minimum: 0
            - type: 'null'
          title: Temperature
        top_p:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: 'null'
          title: Top P
        stop_sequences:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Stop Sequences
        tools:
          anyOf:
            - items:
                anyOf:
                  - $ref: '#/components/schemas/ToolParam'
                  - $ref: '#/components/schemas/WebSearchToolParam'
              type: array
            - type: 'null'
          title: Tools
        tool_choice:
          anyOf:
            - oneOf:
                - $ref: '#/components/schemas/ToolChoiceAutoParam'
                - $ref: '#/components/schemas/ToolChoiceAnyParam'
                - $ref: '#/components/schemas/ToolChoiceToolParam'
                - $ref: '#/components/schemas/ToolChoiceNoneParam'
              discriminator:
                propertyName: type
                mapping:
                  any:
                    $ref: '#/components/schemas/ToolChoiceAnyParam'
                  auto:
                    $ref: '#/components/schemas/ToolChoiceAutoParam'
                  none:
                    $ref: '#/components/schemas/ToolChoiceNoneParam'
                  tool:
                    $ref: '#/components/schemas/ToolChoiceToolParam'
            - type: 'null'
          title: Tool Choice
        thinking:
          anyOf:
            - oneOf:
                - $ref: '#/components/schemas/ThinkingConfigEnabledParam'
                - $ref: '#/components/schemas/ThinkingConfigDisabledParam'
                - $ref: '#/components/schemas/ThinkingConfigAdaptiveParam'
              discriminator:
                propertyName: type
                mapping:
                  adaptive:
                    $ref: '#/components/schemas/ThinkingConfigAdaptiveParam'
                  disabled:
                    $ref: '#/components/schemas/ThinkingConfigDisabledParam'
                  enabled:
                    $ref: '#/components/schemas/ThinkingConfigEnabledParam'
            - type: 'null'
          title: Thinking
        output_config:
          anyOf:
            - $ref: '#/components/schemas/OutputConfigParam'
            - type: 'null'
      type: object
      required:
        - model
        - max_tokens
        - messages
      title: MessagesRequest
      description: |-
        Stateless Messages API endpoint (Anthropic Messages API compatibility).

        Request surface is intentionally limited to what maps into our internal
        `/v1/chat/completions` pipeline.
      examples:
        - max_tokens: 512
          messages:
            - content: Draft a release note for an API latency improvement.
              role: user
          model: claude-sonnet-4.5
    AnthropicMessageResponse:
      properties:
        id:
          type: string
          title: Id
        type:
          type: string
          const: message
          title: Type
          default: message
        role:
          type: string
          const: assistant
          title: Role
          default: assistant
        model:
          type: string
          title: Model
        content:
          items:
            oneOf:
              - $ref: '#/components/schemas/AnthropicTextBlockResponse'
              - $ref: '#/components/schemas/AnthropicThinkingBlockResponse'
              - $ref: '#/components/schemas/AnthropicImageBlockResponse'
              - $ref: '#/components/schemas/AnthropicSearchResultBlockResponse'
              - $ref: '#/components/schemas/AnthropicToolUseBlockResponse'
            discriminator:
              propertyName: type
              mapping:
                image:
                  $ref: '#/components/schemas/AnthropicImageBlockResponse'
                search_result:
                  $ref: '#/components/schemas/AnthropicSearchResultBlockResponse'
                text:
                  $ref: '#/components/schemas/AnthropicTextBlockResponse'
                thinking:
                  $ref: '#/components/schemas/AnthropicThinkingBlockResponse'
                tool_use:
                  $ref: '#/components/schemas/AnthropicToolUseBlockResponse'
          type: array
          title: Content
        stop_reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Stop Reason
        stop_sequence:
          anyOf:
            - type: string
            - type: 'null'
          title: Stop Sequence
        usage:
          anyOf:
            - $ref: '#/components/schemas/AnthropicUsageResponse'
            - type: 'null'
        created:
          type: integer
          title: Created
      additionalProperties: true
      type: object
      required:
        - id
        - model
        - content
        - created
      title: AnthropicMessageResponse
      examples:
        - content:
            - text: >-
                The CAP theorem states that a distributed system can guarantee
                at most two of consistency, availability, and partition
                tolerance at the same time once network partitions are possible.
              type: text
          created: 1743393600
          id: msg_123
          model: claude-sonnet-4.5
          role: assistant
          stop_reason: end_turn
          type: message
          usage:
            input_tokens: 17
            output_tokens: 32
    ErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/ErrorBody'
      additionalProperties: true
      type: object
      required:
        - error
      title: ErrorEnvelope
      examples:
        - error:
            message: The request body is invalid.
            type: invalid_request_error
    HTTPValidationErrorResponse:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationErrorItem'
          type: array
          title: Detail
      additionalProperties: true
      type: object
      required:
        - detail
      title: HTTPValidationErrorResponse
    MessageParam:
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
          title: Role
        content:
          anyOf:
            - type: string
            - items:
                oneOf:
                  - $ref: '#/components/schemas/TextBlockParam'
                  - $ref: '#/components/schemas/ImageBlockParam'
                  - $ref: '#/components/schemas/DocumentBlockParam'
                  - $ref: '#/components/schemas/SearchResultBlockParam'
                  - $ref: '#/components/schemas/ThinkingBlockParam'
                  - $ref: '#/components/schemas/RedactedThinkingBlockParam'
                  - $ref: '#/components/schemas/ToolUseBlockParam'
                  - $ref: '#/components/schemas/ToolResultBlockParam'
                discriminator:
                  propertyName: type
                  mapping:
                    document:
                      $ref: '#/components/schemas/DocumentBlockParam'
                    image:
                      $ref: '#/components/schemas/ImageBlockParam'
                    redacted_thinking:
                      $ref: '#/components/schemas/RedactedThinkingBlockParam'
                    search_result:
                      $ref: '#/components/schemas/SearchResultBlockParam'
                    text:
                      $ref: '#/components/schemas/TextBlockParam'
                    thinking:
                      $ref: '#/components/schemas/ThinkingBlockParam'
                    tool_result:
                      $ref: '#/components/schemas/ToolResultBlockParam'
                    tool_use:
                      $ref: '#/components/schemas/ToolUseBlockParam'
              type: array
          title: Content
      type: object
      required:
        - role
        - content
      title: MessageParam
    TextBlockParam:
      properties:
        type:
          type: string
          const: text
          title: Type
        text:
          type: string
          title: Text
          description: Plain text content block.
          examples:
            - Explain the CAP theorem in one paragraph.
      type: object
      required:
        - type
        - text
      title: TextBlockParam
    ToolParam:
      properties:
        name:
          type: string
          title: Name
          description: Tool name exposed to the model.
          examples:
            - get_weather
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        input_schema:
          additionalProperties: true
          type: object
          title: Input Schema
      type: object
      required:
        - name
        - input_schema
      title: ToolParam
    WebSearchToolParam:
      properties:
        type:
          type: string
          const: web_search_20250305
          title: Type
        name:
          type: string
          const: web_search
          title: Name
      type: object
      required:
        - type
        - name
      title: WebSearchToolParam
    ToolChoiceAutoParam:
      properties:
        type:
          type: string
          const: auto
          title: Type
        disable_parallel_tool_use:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Disable Parallel Tool Use
      type: object
      required:
        - type
      title: ToolChoiceAutoParam
    ToolChoiceAnyParam:
      properties:
        type:
          type: string
          const: any
          title: Type
        disable_parallel_tool_use:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Disable Parallel Tool Use
      type: object
      required:
        - type
      title: ToolChoiceAnyParam
    ToolChoiceToolParam:
      properties:
        type:
          type: string
          const: tool
          title: Type
        name:
          type: string
          title: Name
        disable_parallel_tool_use:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Disable Parallel Tool Use
      type: object
      required:
        - type
        - name
      title: ToolChoiceToolParam
    ToolChoiceNoneParam:
      properties:
        type:
          type: string
          const: none
          title: Type
      type: object
      required:
        - type
      title: ToolChoiceNoneParam
    ThinkingConfigEnabledParam:
      properties:
        type:
          type: string
          const: enabled
          title: Type
        budget_tokens:
          anyOf:
            - type: integer
              minimum: 0
            - type: 'null'
          title: Budget Tokens
      type: object
      required:
        - type
      title: ThinkingConfigEnabledParam
    ThinkingConfigDisabledParam:
      properties:
        type:
          type: string
          const: disabled
          title: Type
      type: object
      required:
        - type
      title: ThinkingConfigDisabledParam
    ThinkingConfigAdaptiveParam:
      properties:
        type:
          type: string
          const: adaptive
          title: Type
      type: object
      required:
        - type
      title: ThinkingConfigAdaptiveParam
    OutputConfigParam:
      properties:
        effort:
          anyOf:
            - type: string
              enum:
                - low
                - medium
                - high
                - max
            - type: 'null'
          title: Effort
      type: object
      title: OutputConfigParam
    AnthropicTextBlockResponse:
      properties:
        type:
          type: string
          const: text
          title: Type
        text:
          type: string
          title: Text
      additionalProperties: true
      type: object
      required:
        - type
        - text
      title: AnthropicTextBlockResponse
    AnthropicThinkingBlockResponse:
      properties:
        type:
          type: string
          const: thinking
          title: Type
        thinking:
          type: string
          title: Thinking
        signature:
          anyOf:
            - type: string
            - type: 'null'
          title: Signature
      additionalProperties: true
      type: object
      required:
        - type
        - thinking
      title: AnthropicThinkingBlockResponse
    AnthropicImageBlockResponse:
      properties:
        type:
          type: string
          const: image
          title: Type
        source:
          $ref: '#/components/schemas/AnthropicImageSourceResponse'
      additionalProperties: true
      type: object
      required:
        - type
        - source
      title: AnthropicImageBlockResponse
    AnthropicSearchResultBlockResponse:
      properties:
        type:
          type: string
          const: search_result
          title: Type
        title:
          anyOf:
            - type: string
            - type: 'null'
          title: Title
        source:
          anyOf:
            - type: string
            - type: 'null'
          title: Source
        content:
          items:
            $ref: '#/components/schemas/AnthropicTextBlockResponse'
          type: array
          title: Content
      additionalProperties: true
      type: object
      required:
        - type
      title: AnthropicSearchResultBlockResponse
    AnthropicToolUseBlockResponse:
      properties:
        type:
          type: string
          const: tool_use
          title: Type
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
        input:
          anyOf:
            - additionalProperties: true
              type: object
            - type: string
          title: Input
      additionalProperties: true
      type: object
      required:
        - type
      title: AnthropicToolUseBlockResponse
    AnthropicUsageResponse:
      properties:
        input_tokens:
          type: integer
          title: Input Tokens
        output_tokens:
          type: integer
          title: Output Tokens
        cache_read_input_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Cache Read Input Tokens
      additionalProperties: true
      type: object
      required:
        - input_tokens
        - output_tokens
      title: AnthropicUsageResponse
    ErrorBody:
      properties:
        type:
          type: string
          title: Type
          description: Stable machine-readable error type.
        message:
          type: string
          title: Message
          description: Human-readable error message.
        code:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Code
        param:
          anyOf:
            - type: string
            - type: 'null'
          title: Param
      additionalProperties: true
      type: object
      required:
        - type
        - message
      title: ErrorBody
    ValidationErrorItem:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Loc
        msg:
          type: string
          title: Msg
        type:
          type: string
          title: Type
      additionalProperties: true
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationErrorItem
    ImageBlockParam:
      properties:
        type:
          type: string
          const: image
          title: Type
        source:
          oneOf:
            - $ref: '#/components/schemas/Base64ImageSourceParam'
            - $ref: '#/components/schemas/URLImageSourceParam'
          title: Source
          discriminator:
            propertyName: type
            mapping:
              base64:
                $ref: '#/components/schemas/Base64ImageSourceParam'
              url:
                $ref: '#/components/schemas/URLImageSourceParam'
      type: object
      required:
        - type
        - source
      title: ImageBlockParam
    DocumentBlockParam:
      properties:
        type:
          type: string
          const: document
          title: Type
        source:
          oneOf:
            - $ref: '#/components/schemas/Base64PDFSourceParam'
            - $ref: '#/components/schemas/URLPDFSourceParam'
            - $ref: '#/components/schemas/PlainTextSourceParam'
            - $ref: '#/components/schemas/ContentBlockSourceParam'
          title: Source
          discriminator:
            propertyName: type
            mapping:
              base64:
                $ref: '#/components/schemas/Base64PDFSourceParam'
              content:
                $ref: '#/components/schemas/ContentBlockSourceParam'
              text:
                $ref: '#/components/schemas/PlainTextSourceParam'
              url:
                $ref: '#/components/schemas/URLPDFSourceParam'
        title:
          anyOf:
            - type: string
            - type: 'null'
          title: Title
      type: object
      required:
        - type
        - source
      title: DocumentBlockParam
    SearchResultBlockParam:
      properties:
        type:
          type: string
          const: search_result
          title: Type
        title:
          anyOf:
            - type: string
            - type: 'null'
          title: Title
        source:
          anyOf:
            - type: string
            - type: 'null'
          title: Source
        content:
          items:
            $ref: '#/components/schemas/TextBlockParam'
          type: array
          title: Content
      type: object
      required:
        - type
      title: SearchResultBlockParam
    ThinkingBlockParam:
      properties:
        type:
          type: string
          const: thinking
          title: Type
        thinking:
          type: string
          title: Thinking
        signature:
          anyOf:
            - type: string
            - type: 'null'
          title: Signature
      type: object
      required:
        - type
        - thinking
      title: ThinkingBlockParam
    RedactedThinkingBlockParam:
      properties:
        type:
          type: string
          const: redacted_thinking
          title: Type
        data:
          type: string
          title: Data
      type: object
      required:
        - type
        - data
      title: RedactedThinkingBlockParam
    ToolUseBlockParam:
      properties:
        type:
          type: string
          const: tool_use
          title: Type
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        input:
          additionalProperties: true
          type: object
          title: Input
      type: object
      required:
        - type
        - id
        - name
      title: ToolUseBlockParam
    ToolResultBlockParam:
      properties:
        type:
          type: string
          const: tool_result
          title: Type
        tool_use_id:
          type: string
          title: Tool Use Id
        content:
          anyOf:
            - type: string
            - items:
                additionalProperties: true
                type: object
              type: array
          title: Content
          default: ''
      type: object
      required:
        - type
        - tool_use_id
      title: ToolResultBlockParam
    AnthropicImageSourceResponse:
      properties:
        type:
          type: string
          const: url
          title: Type
        url:
          type: string
          title: Url
      additionalProperties: true
      type: object
      required:
        - type
        - url
      title: AnthropicImageSourceResponse
    Base64ImageSourceParam:
      properties:
        type:
          type: string
          const: base64
          title: Type
        media_type:
          type: string
          enum:
            - image/jpeg
            - image/png
            - image/gif
            - image/webp
          title: Media Type
        data:
          type: string
          title: Data
      type: object
      required:
        - type
        - media_type
        - data
      title: Base64ImageSourceParam
    URLImageSourceParam:
      properties:
        type:
          type: string
          const: url
          title: Type
        url:
          type: string
          minLength: 1
          format: uri
          title: Url
      type: object
      required:
        - type
        - url
      title: URLImageSourceParam
    Base64PDFSourceParam:
      properties:
        type:
          type: string
          const: base64
          title: Type
        media_type:
          type: string
          const: application/pdf
          title: Media Type
          default: application/pdf
        data:
          type: string
          title: Data
      type: object
      required:
        - type
        - data
      title: Base64PDFSourceParam
    URLPDFSourceParam:
      properties:
        type:
          type: string
          const: url
          title: Type
        url:
          type: string
          minLength: 1
          format: uri
          title: Url
      type: object
      required:
        - type
        - url
      title: URLPDFSourceParam
    PlainTextSourceParam:
      properties:
        type:
          type: string
          const: text
          title: Type
        media_type:
          type: string
          const: text/plain
          title: Media Type
          default: text/plain
        data:
          type: string
          title: Data
      type: object
      required:
        - type
        - data
      title: PlainTextSourceParam
    ContentBlockSourceParam:
      properties:
        type:
          type: string
          const: content
          title: Type
        content:
          anyOf:
            - type: string
            - items:
                additionalProperties: true
                type: object
              type: array
          title: Content
      type: object
      required:
        - type
        - content
      title: ContentBlockSourceParam
  securitySchemes:
    bearerAuth:
      type: http
      description: >-
        Primary authentication for inference endpoints. Send your Naga API key
        as `Authorization: Bearer <api-key>`.
      scheme: bearer
    xApiKeyAuth:
      type: apiKey
      description: >-
        Alternate authentication for inference endpoints. Useful for clients
        that send `x-api-key: <api-key>`.
      in: header
      name: x-api-key

````