> ## 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 a stateless response

> OpenAI Responses-compatible text, vision, structured-output, and function-calling API. Set stream=true for typed lifecycle events.



## OpenAPI

````yaml /openapi.json post /responses
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:
  /responses:
    post:
      summary: Create a stateless response
      description: >-
        OpenAI Responses-compatible text, vision, structured-output, and
        function-calling API. Set stream=true for typed lifecycle events.
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponsesRequest'
      responses:
        '200':
          description: Completed response or SSE stream.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseObject'
            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: []
      x-codeSamples:
        - lang: javascript
          label: TypeScript SDK
          source: >-
            import { NinjaChat } from "@ninjachat/sdk";


            const client = new NinjaChat({ apiKey:
            process.env.NINJACHAT_API_KEY! });


            const response = await client.responses.create({
              model: "ninja/auto",
              input: "Explain the key tradeoffs in one paragraph.",
            });


            console.log(response.output_text);
        - lang: python
          label: Python SDK
          source: |-
            import os
            from ninjachat import NinjaChat

            client = NinjaChat(api_key=os.environ["NINJACHAT_API_KEY"])

            response = client.responses.create(
                model="ninja/auto",
                input="Explain the key tradeoffs in one paragraph.",
            )

            print(response["output_text"])
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:
    ResponsesRequest:
      type: object
      properties:
        model:
          type: string
          minLength: 1
          maxLength: 160
        models:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 160
          minItems: 1
          maxItems: 15
        input:
          anyOf:
            - type: string
              minLength: 1
            - type: array
              items:
                anyOf:
                  - type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - message
                      role:
                        type: string
                        enum:
                          - developer
                          - system
                          - user
                          - assistant
                      content:
                        anyOf:
                          - type: string
                            minLength: 1
                          - type: array
                            items:
                              anyOf:
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - input_text
                                    text:
                                      type: string
                                      minLength: 1
                                  required:
                                    - type
                                    - text
                                  additionalProperties: false
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - input_image
                                    image_url:
                                      type: string
                                      minLength: 1
                                      maxLength: 7000000
                                    detail:
                                      type: string
                                      enum:
                                        - auto
                                        - low
                                        - high
                                  required:
                                    - type
                                    - image_url
                                  additionalProperties: false
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - input_file
                                    filename:
                                      type: string
                                      minLength: 1
                                      maxLength: 255
                                    file_data:
                                      type: string
                                      minLength: 1
                                      maxLength: 7000000
                                    file_url:
                                      type: string
                                      maxLength: 4096
                                      format: uri
                                    media_type:
                                      type: string
                                      enum:
                                        - application/pdf
                                        - text/plain
                                        - text/markdown
                                        - text/csv
                                        - application/json
                                  required:
                                    - type
                                  additionalProperties: false
                            minItems: 1
                    required:
                      - role
                      - content
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - function_call
                      call_id:
                        type: string
                        minLength: 1
                        maxLength: 128
                      name:
                        type: string
                        minLength: 1
                        maxLength: 64
                      arguments:
                        type: string
                    required:
                      - type
                      - call_id
                      - name
                      - arguments
                    additionalProperties: false
                  - type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - function_call_output
                      call_id:
                        type: string
                        minLength: 1
                        maxLength: 128
                      output:
                        anyOf:
                          - type: string
                          - type: array
                            items:
                              anyOf:
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - input_text
                                    text:
                                      type: string
                                      minLength: 1
                                  required:
                                    - type
                                    - text
                                  additionalProperties: false
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - input_image
                                    image_url:
                                      type: string
                                      minLength: 1
                                      maxLength: 7000000
                                    detail:
                                      type: string
                                      enum:
                                        - auto
                                        - low
                                        - high
                                  required:
                                    - type
                                    - image_url
                                  additionalProperties: false
                                - type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - input_file
                                    filename:
                                      type: string
                                      minLength: 1
                                      maxLength: 255
                                    file_data:
                                      type: string
                                      minLength: 1
                                      maxLength: 7000000
                                    file_url:
                                      type: string
                                      maxLength: 4096
                                      format: uri
                                    media_type:
                                      type: string
                                      enum:
                                        - application/pdf
                                        - text/plain
                                        - text/markdown
                                        - text/csv
                                        - application/json
                                  required:
                                    - type
                                  additionalProperties: false
                            minItems: 1
                    required:
                      - type
                      - call_id
                      - output
                    additionalProperties: false
              minItems: 1
        instructions:
          type: string
        max_output_tokens:
          type: integer
          exclusiveMinimum: 0
          maximum: 9007199254740991
          description: >-
            Maximum completion tokens, including reasoning where the provider
            counts it. Must fit the selected provider's output and context
            limits. Defaults to 2048 when omitted.
        temperature:
          type: number
          minimum: 0
          maximum: 2
        top_p:
          type: number
          minimum: 0
          maximum: 1
        stream:
          type: boolean
          default: false
        store:
          type: boolean
          enum:
            - false
          default: false
        tools:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
                enum:
                  - function
              name:
                type: string
                minLength: 1
                maxLength: 64
                pattern: ^[a-zA-Z0-9_-]+$
              description:
                type: string
              parameters:
                type: object
                additionalProperties: {}
                default: {}
              strict:
                type: boolean
            required:
              - type
              - name
            additionalProperties: false
        tool_choice:
          anyOf:
            - type: string
              enum:
                - none
                - auto
                - required
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - function
                name:
                  type: string
                  minLength: 1
                  maxLength: 128
              required:
                - type
                - name
              additionalProperties: false
        parallel_tool_calls:
          type: boolean
        text:
          type: object
          properties:
            format:
              oneOf:
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - text
                  required:
                    - type
                  additionalProperties: false
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - json_object
                  required:
                    - type
                  additionalProperties: false
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - json_schema
                    name:
                      type: string
                      minLength: 1
                      maxLength: 128
                    description:
                      type: string
                    schema:
                      type: object
                      additionalProperties: {}
                    strict:
                      type: boolean
                      default: true
                  required:
                    - type
                    - name
                    - schema
                  additionalProperties: false
          additionalProperties: false
        reasoning:
          $ref: '#/components/schemas/ChatReasoning'
        routing:
          $ref: '#/components/schemas/RoutingPolicy'
        metadata:
          type: object
          additionalProperties:
            type: string
            maxLength: 512
        user:
          type: string
          maxLength: 256
      required:
        - input
      additionalProperties: false
    ResponseObject:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          enum:
            - response
        created_at:
          type: integer
        status:
          type: string
          enum:
            - completed
            - incomplete
        error:
          type: 'null'
        incomplete_details:
          type:
            - object
            - 'null'
          properties:
            reason:
              type: string
              enum:
                - max_output_tokens
                - content_filter
          required:
            - reason
          additionalProperties: false
        instructions:
          type:
            - string
            - 'null'
        max_output_tokens:
          type:
            - integer
            - 'null'
        model:
          type: string
          minLength: 1
          maxLength: 160
        output:
          type: array
          items:
            anyOf:
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    type: string
                    enum:
                      - reasoning
                  status:
                    type: string
                    enum:
                      - completed
                      - incomplete
                  summary:
                    type: array
                    items:
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - summary_text
                        text:
                          type: string
                      required:
                        - type
                        - text
                      additionalProperties: false
                required:
                  - id
                  - type
                  - status
                  - summary
                additionalProperties: false
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    type: string
                    enum:
                      - message
                  status:
                    type: string
                    enum:
                      - completed
                      - incomplete
                  role:
                    type: string
                    enum:
                      - assistant
                  content:
                    type: array
                    items:
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - output_text
                        text:
                          type: string
                        annotations:
                          type: array
                          items: {}
                      required:
                        - type
                        - text
                        - annotations
                      additionalProperties: false
                required:
                  - id
                  - type
                  - status
                  - role
                  - content
                additionalProperties: false
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    type: string
                    enum:
                      - function_call
                  status:
                    type: string
                    enum:
                      - completed
                      - incomplete
                  call_id:
                    type: string
                  name:
                    type: string
                  arguments:
                    type: string
                required:
                  - id
                  - type
                  - status
                  - call_id
                  - name
                  - arguments
                additionalProperties: false
        output_text:
          type: string
        parallel_tool_calls:
          type: boolean
        previous_response_id:
          type: 'null'
        store:
          type: boolean
          enum:
            - false
        usage:
          type: object
          properties:
            input_tokens:
              type: integer
              minimum: 0
            input_tokens_details:
              type: object
              properties:
                cached_tokens:
                  type: integer
                  minimum: 0
                cache_creation_tokens:
                  type: integer
                  minimum: 0
              required:
                - cached_tokens
                - cache_creation_tokens
              additionalProperties: false
            output_tokens:
              type: integer
              minimum: 0
            output_tokens_details:
              type: object
              properties:
                reasoning_tokens:
                  type: integer
                  minimum: 0
              required:
                - reasoning_tokens
              additionalProperties: false
            total_tokens:
              type: integer
              minimum: 0
          required:
            - input_tokens
            - input_tokens_details
            - output_tokens
            - output_tokens_details
            - total_tokens
          additionalProperties: false
        cost_usd:
          type: number
          minimum: 0
        provider:
          type:
            - string
            - 'null'
        request_id:
          type: string
        routing:
          $ref: '#/components/schemas/RoutingSummary'
        metadata:
          type: object
          additionalProperties:
            type: string
      required:
        - id
        - object
        - created_at
        - status
        - error
        - incomplete_details
        - instructions
        - max_output_tokens
        - model
        - output
        - output_text
        - parallel_tool_calls
        - previous_response_id
        - store
        - usage
        - cost_usd
        - provider
        - request_id
        - routing
        - metadata
      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
    ChatReasoning:
      type: object
      properties:
        effort:
          type: string
          enum:
            - none
            - minimal
            - low
            - medium
            - high
            - xhigh
        max_tokens:
          type: integer
          minimum: 0
          maximum: 9007199254740991
        enabled:
          type: boolean
      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
    RoutingSummary:
      type: object
      properties:
        strategy:
          type: string
          enum:
            - balanced
            - cost
            - latency
            - quality
        requested_models:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 160
        resolved_model:
          type: string
          minLength: 1
          maxLength: 160
        provider:
          type:
            - string
            - 'null'
        provider_attempts:
          type: array
          items:
            $ref: '#/components/schemas/ProviderAttemptReceipt'
        fallbacks_allowed:
          type: boolean
        data_policy:
          type: string
          enum:
            - default
            - no_training
            - zero_retention
        caching:
          type: string
          enum:
            - auto
        source:
          type: string
          enum:
            - request
            - project
            - default
        router:
          $ref: '#/components/schemas/RouterDecisionSummary'
      required:
        - strategy
        - requested_models
        - resolved_model
        - provider
        - fallbacks_allowed
        - data_policy
      additionalProperties: false
    ProviderAttemptReceipt:
      type: object
      properties:
        provider:
          type: string
        outcome:
          type: string
          enum:
            - served
            - failed_over
            - failed
        attempt_index:
          type: integer
          minimum: 0
      required:
        - provider
        - outcome
        - attempt_index
      additionalProperties: false
    RouterDecisionSummary:
      type: object
      properties:
        id:
          type: string
          enum:
            - ninja/auto
        task:
          type: string
        classified_by:
          type: string
          enum:
            - regex
            - llm
            - llm-cached
        override:
          type:
            - string
            - 'null'
          enum:
            - long_context
            - multilingual
        reasoning:
          type: string
        candidates:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 160
        considered:
          type: array
          items:
            type: object
            properties: {}
      required:
        - id
        - task
        - classified_by
        - override
        - reasoning
        - candidates
        - considered
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: NinjaChat API key
      description: Use an API key created in the NinjaChat developer console.

````