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

# Generate images (legacy path)

> Supported compatibility surface — kept working indefinitely, but not the path for new integrations. Modern equivalent: `POST /images/generations`.

Backward-compatible alias of /images/generations.



## OpenAPI

````yaml /openapi.json post /images
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:
  /images:
    post:
      summary: Generate images (legacy path)
      description: >-
        Supported compatibility surface — kept working indefinitely, but not the
        path for new integrations. Modern equivalent: `POST
        /images/generations`.


        Backward-compatible alias of /images/generations.
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
      responses:
        '200':
          description: Generated images and unit cost.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageGenerationResponse'
        '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: []
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:
    ImageGenerationRequest:
      type: object
      properties:
        prompt:
          type: string
          minLength: 1
          maxLength: 4000
        model:
          type: string
          enum:
            - nova-canvas
            - runway-gen4-image-turbo
            - seedream
            - recraft-v3
            - google-imagen-4
            - nano-banana
            - nano-banana-2
            - nano-banana-pro
            - flux-2-klein
            - flux-2-pro
            - flux-2-max
            - flux-2-flex
            - flux-schnell
            - flux-kontext-pro
            - flux-kontext-max
            - flux-1-pro-ultra
            - flux-1.1-pro
            - flux-1-dev
            - flux-1-fill
            - qwen-image-3
            - qwen-image-max
            - seedream-4.5
            - seedream-5-lite
            - seedream-5-pro
            - flux-2-klein-4b
            - flux-2-klein-9b
            - sdxl-turbo
            - pruna-p-image
            - wan-2.6-image
            - nano-banana-2-lite
            - bria-fibo
            - bria-3.2
            - qwen-image-edit-max
            - wan-2.7-image-edit
            - z-image-turbo
            - qwen-image-2512
            - flux-2-dev
            - stable-diffusion-3.5-large
            - qwen-image-edit-plus
            - hidream-l1-fast
            - flux-krea-dev
            - qwen-image-edit-2511
            - flux-kontext-dev
            - grok-imagine
            - grok-imagine-image-2.0
            - grok-imagine-image-quality
            - gpt-image-2
            - ideogram-v3-quality
            - ideogram-v3-turbo
            - google-imagen-4-ultra
            - google-imagen-4-fast
            - luma-photon
            - minimax-image-01
            - ninja-vision-1
            - flux-pro-ultra
            - flux-dev
          default: nano-banana-2
          description: >-
            Image model ID. Legacy ninja-vision-1 resolves to seedream (Seedream
            4.5); flux-pro-ultra resolves to flux-1-pro-ultra.
        size:
          type: string
          enum:
            - 1920x1920
            - 2560x1440
            - 1440x2560
          default: 1920x1920
        'n':
          type: integer
          minimum: 1
          maximum: 4
          default: 1
        aspect_ratio:
          type: string
          maxLength: 20
        image:
          type: string
          format: uri
        reference_images:
          type: array
          items:
            type: string
            format: uri
          minItems: 1
          maxItems: 14
          description: >-
            Reference image URLs, in order. Use this or image, not both. The
            maximum depends on the model.
        width:
          type: integer
          minimum: 256
          maximum: 2048
        height:
          type: integer
          minimum: 256
          maximum: 2048
        storage:
          type: string
          enum:
            - durable
            - provider
          default: durable
          description: >-
            Optional; defaults to durable. durable copies the output to
            NinjaChat storage and returns a permanent URL. provider skips that
            copy for lower latency and returns the provider's temporary URL or
            inline base64 payload.
      required:
        - prompt
      additionalProperties: false
    ImageGenerationResponse:
      type: object
      properties:
        cost:
          type: object
          properties:
            this_request:
              type: string
            per_image:
              type: string
            per_video:
              type: string
            images:
              type: integer
              minimum: 0
          required:
            - this_request
          additionalProperties: false
        balance:
          type: string
        metadata:
          type: object
          properties:
            latency_ms:
              type: number
              minimum: 0
            group:
              type: string
            search_depth:
              type: string
            results_count:
              type: integer
              minimum: 0
          required:
            - latency_ms
          additionalProperties: false
        created:
          type: integer
        data:
          type: array
          items:
            anyOf:
              - type: object
                properties:
                  url:
                    type: string
                    format: uri
                  revised_prompt:
                    type:
                      - string
                      - 'null'
                required:
                  - url
                additionalProperties: false
              - type: object
                properties:
                  b64_json:
                    type: string
                    minLength: 1
                  mime_type:
                    type: string
                    minLength: 1
                  revised_prompt:
                    type:
                      - string
                      - 'null'
                required:
                  - b64_json
                  - mime_type
                additionalProperties: false
        images:
          type: array
          items:
            anyOf:
              - type: object
                properties:
                  url:
                    type: string
                    format: uri
                  revised_prompt:
                    type:
                      - string
                      - 'null'
                required:
                  - url
                additionalProperties: false
              - type: object
                properties:
                  b64_json:
                    type: string
                    minLength: 1
                  mime_type:
                    type: string
                    minLength: 1
                  revised_prompt:
                    type:
                      - string
                      - 'null'
                required:
                  - b64_json
                  - mime_type
                additionalProperties: false
        model:
          type: string
          minLength: 1
          maxLength: 160
        provider:
          type: string
        storage:
          type: string
          enum:
            - durable
            - provider
        usage:
          type: object
          properties:
            images_generated:
              type: integer
              minimum: 0
          required:
            - images_generated
          additionalProperties: false
        cost_usd:
          type: number
          minimum: 0
        request_id:
          type: string
        routing:
          type: object
          properties:
            provider_attempts:
              type: array
              items:
                type: string
              minItems: 1
            retries:
              type: integer
              minimum: 0
          required:
            - provider_attempts
            - retries
          additionalProperties: false
      required:
        - created
        - data
        - model
        - provider
        - storage
        - usage
        - cost_usd
        - request_id
        - routing
      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
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: NinjaChat API key
      description: Use an API key created in the NinjaChat developer console.

````