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

# Create an Anthropic-compatible message

> Messages compatibility for text, image inputs, JSON output schemas, function tools and SSE. Accepts Authorization bearer or x-api-key. Uses the same metered gateway, routing and idempotency as Chat Completions. Native server tools, file IDs and signed thinking history are not supported; unsupported parameters return explicit errors.



## OpenAPI

````yaml /openapi.json post /messages
openapi: 3.1.0
info:
  title: NinjaChat API
  version: 1.0.0
  description: >-
    Clean-break NinjaChat v1. Chat and Responses bill actual token usage; images
    and videos use catalog unit pricing.
servers:
  - url: https://www.ninjachat.ai/api/v1
security: []
paths:
  /messages:
    post:
      summary: Create an Anthropic-compatible message
      description: >-
        Messages compatibility for text, image inputs, JSON output schemas,
        function tools and SSE. Accepts Authorization bearer or x-api-key. Uses
        the same metered gateway, routing and idempotency as Chat Completions.
        Native server tools, file IDs and signed thinking history are not
        supported; unsupported parameters return explicit errors.
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnthropicMessagesRequest'
      responses:
        '200':
          description: Anthropic Message object or Messages SSE lifecycle.
          content:
            application/json:
              schema:
                type: object
                properties: {}
            text/event-stream:
              schema:
                type: string
        '400':
          description: Invalid or unsupported request parameter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Insufficient balance or project spend limit reached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Gateway error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
        - anthropicApiKey: []
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      schema:
        type: string
        minLength: 1
        maxLength: 255
      description: >-
        Safely retry the same logical write without duplicate billing or
        execution.
  schemas:
    AnthropicMessagesRequest:
      type: object
      properties:
        model:
          type: string
          minLength: 1
          maxLength: 160
        max_tokens:
          type: integer
          exclusiveMinimum: 0
          maximum: 9007199254740991
        messages:
          type: array
          items:
            type: object
            properties:
              role:
                type: string
                enum:
                  - user
                  - assistant
              content:
                anyOf:
                  - type: string
                    minLength: 1
                    maxLength: 100000
                  - type: array
                    items:
                      anyOf:
                        - type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - text
                            text:
                              type: string
                              minLength: 1
                              maxLength: 100000
                          required:
                            - type
                            - text
                          additionalProperties: false
                        - type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - image
                            source:
                              oneOf:
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - url
                                    url:
                                      type: string
                                      format: uri
                                  required:
                                    - type
                                    - url
                                  additionalProperties: false
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - base64
                                    media_type:
                                      type: string
                                      enum:
                                        - image/jpeg
                                        - image/png
                                        - image/gif
                                        - image/webp
                                    data:
                                      type: string
                                      minLength: 1
                                      maxLength: 7000000
                                  required:
                                    - type
                                    - media_type
                                    - data
                                  additionalProperties: false
                          required:
                            - type
                            - source
                          additionalProperties: false
                        - type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - document
                            source:
                              oneOf:
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - base64
                                    media_type:
                                      type: string
                                      enum:
                                        - application/pdf
                                    data:
                                      type: string
                                      minLength: 1
                                      maxLength: 7000000
                                  required:
                                    - type
                                    - media_type
                                    - data
                                  additionalProperties: false
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - url
                                    url:
                                      type: string
                                      maxLength: 4096
                                      format: uri
                                  required:
                                    - type
                                    - url
                                  additionalProperties: false
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - text
                                    media_type:
                                      type: string
                                      enum:
                                        - text/plain
                                    data:
                                      type: string
                                      minLength: 1
                                      maxLength: 100000
                                  required:
                                    - type
                                    - media_type
                                    - data
                                  additionalProperties: false
                          required:
                            - type
                            - source
                          additionalProperties: false
                        - type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - tool_use
                            id:
                              type: string
                              minLength: 1
                              maxLength: 128
                            name:
                              type: string
                              minLength: 1
                              maxLength: 64
                            input:
                              type: object
                              additionalProperties: {}
                          required:
                            - type
                            - id
                            - name
                            - input
                          additionalProperties: false
                        - type: object
                          properties:
                            type:
                              type: string
                              enum:
                                - tool_result
                            tool_use_id:
                              type: string
                              minLength: 1
                              maxLength: 128
                            content:
                              anyOf:
                                - type: string
                                - type: array
                                  items:
                                    anyOf:
                                      - type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - text
                                          text:
                                            type: string
                                            minLength: 1
                                            maxLength: 100000
                                        required:
                                          - type
                                          - text
                                        additionalProperties: false
                                      - type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - image
                                          source:
                                            oneOf:
                                              - type: object
                                                properties:
                                                  type:
                                                    type: string
                                                    enum:
                                                      - url
                                                  url:
                                                    type: string
                                                    format: uri
                                                required:
                                                  - type
                                                  - url
                                                additionalProperties: false
                                              - type: object
                                                properties:
                                                  type:
                                                    type: string
                                                    enum:
                                                      - base64
                                                  media_type:
                                                    type: string
                                                    enum:
                                                      - image/jpeg
                                                      - image/png
                                                      - image/gif
                                                      - image/webp
                                                  data:
                                                    type: string
                                                    minLength: 1
                                                    maxLength: 7000000
                                                required:
                                                  - type
                                                  - media_type
                                                  - data
                                                additionalProperties: false
                                        required:
                                          - type
                                          - source
                                        additionalProperties: false
                                      - type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - document
                                          source:
                                            oneOf:
                                              - type: object
                                                properties:
                                                  type:
                                                    type: string
                                                    enum:
                                                      - base64
                                                  media_type:
                                                    type: string
                                                    enum:
                                                      - application/pdf
                                                  data:
                                                    type: string
                                                    minLength: 1
                                                    maxLength: 7000000
                                                required:
                                                  - type
                                                  - media_type
                                                  - data
                                                additionalProperties: false
                                              - type: object
                                                properties:
                                                  type:
                                                    type: string
                                                    enum:
                                                      - url
                                                  url:
                                                    type: string
                                                    maxLength: 4096
                                                    format: uri
                                                required:
                                                  - type
                                                  - url
                                                additionalProperties: false
                                              - type: object
                                                properties:
                                                  type:
                                                    type: string
                                                    enum:
                                                      - text
                                                  media_type:
                                                    type: string
                                                    enum:
                                                      - text/plain
                                                  data:
                                                    type: string
                                                    minLength: 1
                                                    maxLength: 100000
                                                required:
                                                  - type
                                                  - media_type
                                                  - data
                                                additionalProperties: false
                                        required:
                                          - type
                                          - source
                                        additionalProperties: false
                            is_error:
                              type: boolean
                          required:
                            - type
                            - tool_use_id
                          additionalProperties: false
                    minItems: 1
                    maxItems: 100
            required:
              - role
              - content
            additionalProperties: false
          minItems: 1
          maxItems: 100
        system:
          anyOf:
            - type: string
            - type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                    enum:
                      - text
                  text:
                    type: string
                    minLength: 1
                    maxLength: 100000
                required:
                  - type
                  - text
                additionalProperties: false
        stream:
          type: boolean
        temperature:
          type: number
          minimum: 0
          maximum: 1
        top_p:
          type: number
          minimum: 0
          maximum: 1
        stop_sequences:
          type: array
          items:
            type: string
          maxItems: 4
        tools:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                minLength: 1
                maxLength: 64
              description:
                type: string
                maxLength: 1024
              input_schema:
                type: object
                additionalProperties: {}
              strict:
                type: boolean
            required:
              - name
              - input_schema
            additionalProperties: false
          maxItems: 32
        tool_choice:
          anyOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - auto
                    - any
                    - none
                disable_parallel_tool_use:
                  type: boolean
              required:
                - type
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - tool
                name:
                  type: string
                disable_parallel_tool_use:
                  type: boolean
              required:
                - type
                - name
              additionalProperties: false
        metadata:
          type: object
          properties:
            user_id:
              type: string
              maxLength: 256
          additionalProperties: false
        output_config:
          type: object
          properties:
            format:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - json_schema
                schema:
                  type: object
                  additionalProperties: {}
              required:
                - type
                - schema
              additionalProperties: false
          required:
            - format
          additionalProperties: false
        routing:
          $ref: '#/components/schemas/RoutingPolicy'
      required:
        - model
        - max_tokens
        - messages
      additionalProperties: false
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
            param:
              type:
                - string
                - 'null'
          required:
            - message
            - type
            - code
          additionalProperties: false
      required:
        - error
      additionalProperties: false
    RoutingPolicy:
      type: object
      properties:
        strategy:
          type: string
          enum:
            - balanced
            - cost
            - latency
            - quality
        providers:
          type: object
          properties:
            only:
              type: array
              items:
                type: string
                minLength: 1
                maxLength: 128
              minItems: 1
              maxItems: 20
            exclude:
              type: array
              items:
                type: string
                minLength: 1
                maxLength: 128
              minItems: 1
              maxItems: 20
            order:
              type: array
              items:
                type: string
                minLength: 1
                maxLength: 128
              minItems: 1
              maxItems: 20
          additionalProperties: false
        allow_fallbacks:
          type: boolean
          default: true
        require_parameters:
          type: boolean
          default: true
        data_policy:
          type: string
          enum:
            - default
            - no_training
            - zero_retention
          default: default
        caching:
          type: string
          enum:
            - auto
        max_cost_usd:
          type: number
          exclusiveMinimum: 0
          maximum: 1000
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: NinjaChat API key
      description: Use an API key created in the NinjaChat developer console.
    anthropicApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        NinjaChat API key accepted by the Anthropic Messages compatibility
        endpoint.

````