NinjaChat Images API
The Images API from NinjaChat — 2 operation(s) for images.
The Images API from NinjaChat — 2 operation(s) for images.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
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.curl "https://apis.io/api/v1/apis/ninjachat-ai:ninjachat-ai-images-api"
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.
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: 3.2.0
info:
title: NinjaChat Images 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: Images
paths:
/images/generations:
post:
summary: Generate images
description: storage is optional and defaults to durable, which copies output to NinjaChat storage and returns a permanent URL. Set storage=provider to skip that copy for lower latency; provider mode returns either a temporary provider URL or b64_json plus mime_type.
security:
- bearerAuth: []
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'
parameters:
- $ref: '#/components/parameters/IdempotencyKey'
x-codeSamples:
- lang: javascript
label: TypeScript SDK
source: "import { NinjaChat } from \"@ninjachat/sdk\";\n\nconst client = new NinjaChat({ apiKey: process.env.NINJACHAT_API_KEY! });\n\nconst image = await client.images.generate({\n model: \"flux-2-pro\",\n prompt: \"A glass observatory above a cloud sea at sunrise\",\n storage: \"provider\", // Lowest latency; use \"durable\" for a permanent URL.\n});\n\nconst output = image.data[0];\nconsole.log(output && \"url\" in output ? output.url : output?.b64_json);"
- lang: python
label: Python SDK
source: "import os\nfrom ninjachat import NinjaChat\n\nclient = NinjaChat(api_key=os.environ[\"NINJACHAT_API_KEY\"])\n\nimage = client.images.generate(\n model=\"flux-2-pro\",\n prompt=\"A glass observatory above a cloud sea at sunrise\",\n storage=\"provider\", # Lowest latency; use \"durable\" for a permanent URL.\n)\n\noutput = image[\"data\"][0]\nprint(output.get(\"url\") or output.get(\"b64_json\"))"
x-ninjachat-status: current
tags:
- Images
operationId: postImagesGenerations
x-operation-id-source: derived
/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.'
security:
- bearerAuth: []
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'
parameters:
- $ref: '#/components/parameters/IdempotencyKey'
x-ninjachat-status: supported_legacy
x-ninjachat-replacement: POST /images/generations
tags:
- Images
operationId: postImages
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:
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
ImageGenerationRequest:
type: object
properties:
content_filter:
type: boolean
enum:
- true
description: Optional explicit acknowledgement of mandatory server-side content filtering. Only true is accepted. Filtering remains enforced when omitted; false is rejected.
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
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:
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