


Generate an image
Send a prompt. Get an image URL.POST /api/v1/images/generations
Response
data[0].url. The response also includes cost and request details.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Generate and edit images with GPT Image, Nano Banana, FLUX and more.



{
"model": "flux-2-klein",
"prompt": "A golden retriever puppy in autumn leaves, soft lighting, photorealistic",
"size": "1920x1920",
"n": 1
}
{
"created": 1787529600,
"model": "flux-2-klein",
"provider": "...",
"data": [{"url": "https://cdn.../generated-abc123.webp", "revised_prompt": "..."}],
"usage": {"images_generated": 1},
"cost_usd": 0.014,
"request_id": "req_...",
"routing": {"provider_attempts": ["..."], "retries": 0}
}
data[0].url. The response also includes cost and request details.
| Parameter | Default | Description |
|---|---|---|
prompt | required | Be specific — subject, style, lighting, composition. Max 4,000 chars. |
model | nano-banana-2 | Choose from the model catalog. |
size | 1920x1920 | Exactly one of 1920x1920 (square), 2560x1440 (landscape), 1440x2560 (portrait). |
n | 1 | 1–4 images; each is billed. |
image | — | Public HTTPS reference URL for image-to-image. |
reference_images | — | Ordered HTTPS reference URLs; up to 14, with a lower limit on some models. Use this or image, not both. |
storage | durable | durable returns a permanent NinjaChat URL; provider skips the copy and may return a temporary URL or inline image data. |
aspect_ratio | — | Aspect ratio for models that support it directly, e.g. 16:9, 1:1 (Nano Banana, Imagen 4, FLUX.2 Flex). |
width | — | Image width in pixels, 256–2048 (FLUX models only). |
height | — | Image height in pixels, 256–2048 (FLUX models only). |
size is a strict enum — 1024x1024 and other values are rejected with validation_error. Pick one of the three.import { NinjaChat } from "@ninjachat/sdk";
const client = new NinjaChat({ apiKey: process.env.NINJACHAT_API_KEY! });
const image = await client.images.generate({
model: "flux-2-klein",
prompt: "A mountain landscape at sunset",
size: "1920x1920",
});
console.log(image.data[0].url);
import os
from ninjachat import NinjaChat
client = NinjaChat(api_key=os.environ["NINJACHAT_API_KEY"])
image = client.images.generate(
model="flux-2-klein",
prompt="A mountain landscape at sunset",
size="1920x1920",
)
print(image["data"][0]["url"])