NinjaChat Messages API

The Messages API from NinjaChat — 1 operation(s) for messages.

GitHub OpenAPI

Operations 1

POST /messages Create an Anthropic-compatible message #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/ninjachat-ai:ninjachat-ai-messages-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

ninjachat-ai-messages-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: NinjaChat Messages 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
tags:
- name: Messages
paths:
  /messages:
    post:
      summary: Create an Anthropic-compatible message
      security:
      - bearerAuth: []
      - anthropicApiKey: []
      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.
      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'
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      x-ninjachat-status: current
      tags:
      - Messages
      operationId: postMessages
      x-operation-id-source: derived
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:
    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
    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
    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
  securitySchemes:
    managementKey:
      type: http
      scheme: bearer
      bearerFormat: nj_mk_...
      description: Account-scoped management credential created by the account owner after email verification. Inference keys cannot access these endpoints; management keys cannot run inference.
    anthropicApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: NinjaChat API key accepted by the Anthropic Messages compatibility endpoint.
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: NinjaChat API key
      description: Use an API key created in the NinjaChat developer console.
x-ninjachat-contract-sha256: df530775ec7be5779917a6c4c5b6015b760809e62fd002827541bf6cac66310e