> ## 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.

# Batch Requests

> Send multiple requests in a single HTTP call. Each item is processed independently and billed as if it were a separate request to the corresponding endpoint.



## OpenAPI

````yaml /openapi.json post /api/v1/batch
openapi: 3.1.0
info:
  title: NinjaChat API
  version: 1.0.0
  description: >-
    Access 40+ AI models through a unified API — chat, image generation, video
    generation, and web search. One API key, one endpoint per type, just change
    the `model` parameter.
servers:
  - url: https://www.ninjachat.ai
security:
  - bearerAuth: []
paths:
  /api/v1/batch:
    post:
      tags:
        - Endpoints
      summary: Batch Requests
      description: >-
        Send multiple requests in a single HTTP call. Each item is processed
        independently and billed as if it were a separate request to the
        corresponding endpoint.
      operationId: batchRequests
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - requests
              properties:
                requests:
                  type: array
                  minItems: 1
                  maxItems: 50
                  items:
                    type: object
                    required:
                      - id
                      - endpoint
                      - body
                    properties:
                      id:
                        type: string
                        description: Client-defined identifier used to match responses.
                      endpoint:
                        type: string
                        description: >-
                          Target endpoint path (e.g. /api/v1/chat,
                          /api/v1/images, /api/v1/search).
                      body:
                        type: object
                        description: JSON body for the underlying request.
                  description: List of requests to execute in batch.
            example:
              requests:
                - id: chat-1
                  endpoint: /api/v1/chat
                  body:
                    model: gpt-5
                    messages:
                      - role: user
                        content: Summarize this article about AI safety.
                - id: image-1
                  endpoint: /api/v1/images
                  body:
                    model: flux-2-klein
                    prompt: A futuristic city skyline at sunset, concept art
      responses:
        '200':
          description: Batch responses, one per input request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  responses:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Matches the request id.
                        status:
                          type: integer
                          example: 200
                        body:
                          type: object
                          description: Raw JSON body returned from the underlying endpoint.
                  cost:
                    $ref: '#/components/schemas/Cost'
        '400':
          description: Invalid batch request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Insufficient credits.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    Cost:
      type: object
      properties:
        this_request:
          type: string
          example: $0.006
          description: Cost of this request.
    ErrorResponse:
      type: object
      description: >-
        OpenAI-compatible error. The top-level `message`, `code`, and
        `request_id` mirror fields inside `error` for convenience.
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error description.
            type:
              type: string
              description: >-
                Error category: invalid_request_error, authentication_error,
                rate_limit_error, insufficient_quota, or api_error.
            code:
              type: string
              description: Machine-readable error code.
            param:
              type: string
              nullable: true
              description: The request parameter that caused the error, if any.
        message:
          type: string
          description: Same as error.message.
        code:
          type: string
          description: Same as error.code.
        request_id:
          type: string
          description: Unique request ID, useful when contacting support.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key starting with nj_sk_

````