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

# Image Generation

> Generate images from text prompts using 6 different models. Supports text-to-image and image-to-image editing with a reference URL. Cost varies by model — from $0.03 to $0.10 per image.



## OpenAPI

````yaml /openapi.json post /api/v1/images
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/images:
    post:
      tags:
        - Endpoints
      summary: Image Generation
      description: >-
        Generate images from text prompts using 6 different models. Supports
        text-to-image and image-to-image editing with a reference URL. Cost
        varies by model — from $0.03 to $0.10 per image.
      operationId: generateImages
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - prompt
              properties:
                prompt:
                  type: string
                  minLength: 1
                  maxLength: 4000
                  description: Image description.
                model:
                  type: string
                  default: flux-2-klein
                  enum:
                    - flux-kontext-max
                    - flux-2-flex
                    - flux-1-pro-ultra
                    - recraft-v3
                    - google-imagen-4
                    - nano-banana-pro
                    - seedream
                    - flux-2-pro
                    - flux-kontext-pro
                    - nano-banana-2
                    - flux-1-fill
                    - flux-2-klein
                    - nano-banana
                  description: >-
                    Image model to use. **$0.10/img:** `flux-kontext-max`.
                    **$0.08/img:** `flux-2-flex`, `flux-1-pro-ultra`,
                    `recraft-v3`, `google-imagen-4`, `nano-banana-pro`,
                    `seedream`. **$0.05/img:** `flux-2-pro`, `flux-kontext-pro`,
                    `nano-banana-2`, `flux-1-fill`. **$0.03/img:**
                    `flux-2-klein`, `nano-banana`.
                size:
                  type: string
                  enum:
                    - 1920x1920
                    - 2560x1440
                    - 1440x2560
                  default: 1920x1920
                  description: >-
                    Output size: 1920x1920 (square, 1:1), 2560x1440 (landscape,
                    16:9), or 1440x2560 (portrait, 9:16).
                'n':
                  type: integer
                  minimum: 1
                  maximum: 4
                  default: 1
                  description: Number of images to generate.
                image:
                  type: string
                  format: uri
                  description: >-
                    Reference image URL for image-to-image editing. Must be a
                    publicly accessible HTTPS URL.
            examples:
              flux-1-pro-ultra:
                summary: FLUX.1 Pro Ultra (highest quality)
                value:
                  model: flux-1-pro-ultra
                  prompt: >-
                    A cyberpunk cityscape at night with neon signs and rain,
                    photorealistic, 8k detail
                  size: 2560x1440
                  'n': 1
              flux-2-klein:
                summary: FLUX.2 Klein (fastest)
                value:
                  model: flux-2-klein
                  prompt: A cute cat wearing sunglasses, cartoon style
                  size: 1920x1920
              imagen4:
                summary: Google Imagen 4
                value:
                  model: google-imagen-4
                  prompt: A photorealistic product shot of a luxury watch on marble
                  size: 1920x1920
      responses:
        '200':
          description: Generated images.
          content:
            application/json:
              schema:
                type: object
                properties:
                  model:
                    type: string
                    example: flux-1-pro-ultra
                  images:
                    type: array
                    items:
                      type: object
                      properties:
                        url:
                          type: string
                        revised_prompt:
                          type: string
                  usage:
                    type: object
                    properties:
                      images_generated:
                        type: integer
                  cost:
                    type: object
                    properties:
                      this_request:
                        type: string
                        example: $0.10
                      per_image:
                        type: string
                        example: $0.10
                      images:
                        type: integer
                        example: 1
                  metadata:
                    type: object
                    properties:
                      latency_ms:
                        type: integer
                      size:
                        type: string
        '400':
          description: Invalid 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'
        '502':
          description: Image generation failed upstream.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    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_

````