Images
POST /v1/images/generations is the unified OpenAI-style image endpoint used by nano, gemini, flux, qwen / Wan, gpt-image and the Tencent-backed image models. It is synchronous by default: the call returns when the image is ready. Add async to get a task back first and poll GET /v1/images/generations/{id}.
Request
POST /v1/images/generations with JSON and a Bearer key. model and prompt are required; model takes an id from "Model families" below. Common fields: n, size, aspect_ratio, resolution, images (reference image URLs).
A model id that is not in "Model families" is still forwarded unchanged by the original handler; see "gpt-image and other models".
curl https://api.novapi.ai/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana",
"prompt": "A cozy wooden cabin in a snowy forest at dusk, warm window light",
"n": 1,
"size": "1536x1024"
}'Python (OpenAI SDK): model, prompt, n and size are SDK parameters; the other unified fields go in extra_body.
from openai import OpenAI
client = OpenAI(base_url="https://api.novapi.ai/v1", api_key="sk-...")
img = client.images.generate(
model="nano-banana",
prompt="A cozy wooden cabin in a snowy forest at dusk, warm window light",
n=1,
extra_body={"aspect_ratio": "3:2", "resolution": "1K"},
)
print(img.data[0].url)TypeScript (OpenAI SDK):
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.novapi.ai/v1", apiKey: process.env.API_KEY });
const img = await client.images.generate({
model: "nano-banana",
prompt: "A cozy wooden cabin in a snowy forest at dusk, warm window light",
n: 1,
aspect_ratio: "3:2",
resolution: "1K",
} as OpenAI.ImageGenerateParams);
console.log(img.data?.[0]?.url);Synchronous response
Synchronous by default: the server waits for the image and answers 200 with an OpenAI-shaped result (created + data[].url) plus the task fields id, status and so on.
The wait is at most 110 seconds. If it is exceeded the call answers 202 with the task object and a Location: /v1/images/generations/{id} header. The task keeps running; do not resubmit (a resubmit is charged again) and fetch the result with GET instead.
If the task fails, a synchronous request answers 502 with error.code image_generation_failed, and the pre-deducted credits are refunded automatically.
{
"id": "img_<task-id>",
"object": "image.generation",
"model": "nano-banana",
"status": "completed",
"created": <unix-seconds>,
"completed_at": <unix-seconds>,
"error": null,
"data": [
{ "url": "https://..." }
]
}Asynchronous and polling
Add "async": true to the body (or the Prefer: respond-async header) and the call answers 202 immediately with the task object (status: queued), a Location header and Retry-After: 3.
curl -i https://api.novapi.ai/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana",
"prompt": "A cozy wooden cabin in a snowy forest at dusk, warm window light",
"async": true
}'
# HTTP/1.1 202 Accepted
# Location: /v1/images/generations/img_<task-id>
# Retry-After: 3{
"id": "img_<task-id>",
"object": "image.generation",
"model": "nano-banana",
"status": "queued",
"created": <unix-seconds>,
"completed_at": null,
"error": null,
"data": []
}Poll GET /v1/images/generations/{id}, about every 3 seconds. A task can only be read by the account that owns the key that created it; any other id returns 404.
| status | Meaning |
|---|---|
queued | Accepted, not started. |
in_progress | Generating. |
completed | Done. data[].url holds the image URL (several when n is above 1). |
failed | error.code is image_generation_failed; error.message has the reason. Pre-deducted credits are refunded. |
curl https://api.novapi.ai/v1/images/generations/img_<task-id> \
-H "Authorization: Bearer $API_KEY"
# status: queued | in_progress | completed | failed
# completed: data[].url holds the image URL(s); failed: error.code and error.messagePython (requests): a complete create-and-poll loop:
import os, time, requests
BASE = "https://api.novapi.ai/v1"
HEAD = {"Authorization": "Bearer " + os.environ["API_KEY"]}
task = requests.post(
BASE + "/images/generations",
headers=HEAD,
json={
"model": "nano-banana",
"prompt": "A cozy wooden cabin in a snowy forest at dusk, warm window light",
"async": True,
},
).json()
while task["status"] in ("queued", "in_progress"):
time.sleep(3)
task = requests.get(BASE + "/images/generations/" + task["id"], headers=HEAD).json()
if task["status"] == "completed":
print([d["url"] for d in task["data"]])
else:
print(task["error"])TypeScript (fetch): a complete create-and-poll loop:
const base = "https://api.novapi.ai/v1";
const headers = { Authorization: "Bearer " + process.env.API_KEY, "Content-Type": "application/json" };
let task = await (
await fetch(base + "/images/generations", {
method: "POST",
headers,
body: JSON.stringify({
model: "nano-banana",
prompt: "A cozy wooden cabin in a snowy forest at dusk, warm window light",
async: true,
}),
})
).json();
while (task.status === "queued" || task.status === "in_progress") {
await new Promise((r) => setTimeout(r, 3000));
task = await (await fetch(base + "/images/generations/" + task.id, { headers })).json();
}
console.log(task.status === "completed" ? task.data.map((d) => d.url) : task.error);Request fields
| Field | Description |
|---|---|
model | Required; see "Model families" below. |
prompt | Required; the image description. |
n | Number of images, default 1; the upper limit depends on the model family (see the table). Above it the call returns 400. |
size | WIDTHxHEIGHT, for example 1024x1024, converted to the nearest aspect ratio the channel accepts; nano / gemini also accept auto. A malformed value returns 400. In its asynchronous mode (sora channel) gpt-image passes size to the channel as is. |
aspect_ratio | Set the aspect ratio directly, for example 16:9; it wins when size is also sent. |
resolution | 1K / 2K / 4K, for nano, gemini and the Tencent-backed models; the tiers you can pick depend on the model. |
images | Reference image URLs, a string or an array; image and image_urls work too. http(s) URLs only, no base64. |
output_format | png, jpeg, ... for nano, gemini and flux only. |
negative_prompt, prompt_extend | negative_prompt is for qwen / Wan and the Tencent-backed models; prompt_extend (boolean) is for qwen / Wan only. |
quality | low / medium / high / auto, for gpt-image in asynchronous mode only; passed to the channel as is. |
async | true: answer 202 with the task object right away, then poll with GET; the Prefer: respond-async header works too. Synchronous by default. |
response_format | For the models behind this facade it can only be url; any other value returns 400. |
| Native channel fields | Native fields such as filesUrl, imageUrls, aspectRatio, numImages and outputFormat are passed through unchanged; when one is sent together with its unified synonym, the native field wins. |
Model families
All of these models use the same endpoint; they differ in the upper limit of n, how size / ratio is handled and the reference image field. Each model reference page lists the model-specific parameters, the resolutions and reference image limits; prices are on /pricing.
| Family | `model` | `n` | `size` / ratio | Reference images | Other fields |
|---|---|---|---|---|---|
| Nano Banana | nano-banana, nano-banana-pro, nano-banana-2, nano-banana-2.1 | 1-4 | Converted to the nearest of 21:9, 16:9, 3:2, 4:3, 5:4, 1:1, 4:5, 3:4, 2:3, 9:16; auto also works | images | resolution, output_format |
| Gemini image | gemini-3-pro-image-preview, gemini-3.1-flash-image-preview | 1-4 | Same as Nano Banana | images | resolution, output_format |
| FLUX Kontext | flux-kontext-pro, flux-kontext-max | Exactly 1 | Nearest of 21:9, 16:9, 3:2, 4:3, 1:1, 3:4, 2:3, 9:16; default 1:1 | images | output_format. Availability follows the model marketplace |
| Qwen / Wan | qwen-image*, qwen-image-edit*, the wan2.5 / wan2.6 / wan2.7 image and i2i models, wanx* (24 ids; see the model marketplace for the full list) | 1-4 | Nearest of 16:9, 4:3, 1:1, 3:4, 9:16; default 1:1 | images; required for edit / i2i models | negative_prompt, prompt_extend |
| GPT-Image | gpt-image-1, gpt-image-1.5, gpt-image-2, gpt-image-2-pro, gpt-image-2-vip, gpt-image-2.5-flare, gpt-image-2.5-sunburst | Synchronous by default, handled by the original handler; exactly 1 with async: true | size and quality are passed to the channel as is | Use images in asynchronous mode | See "gpt-image and other models" |
| Seedream | seedream-5.0-pro, seedream-5.0-lite, seedream-4.5, seedream-4.0 | Up to 4 | Nearest of 16:9, 3:2, 4:3, 1:1, 3:4, 2:3, 9:16; aspect_ratio is validated by the channel | images | resolution, negative_prompt |
| Kling image | kling-image-3.0, kling-image-3.0-omni, kling-image-o1, kling-image-2.1 | Up to 9 | Same as Seedream | images | resolution, negative_prompt |
| Vidu, Hunyuan, Mingmou image | vidu-image-q2, hunyuan-image-3.5-preview, hunyuan-image-3.0, mingmou-image-1.0 | Exactly 1 | Same as Seedream | images; limits on each model page | resolution, negative_prompt |
| Midjourney | mj-v8.2, mj-v8.1, mj-v7, mj-niji7 | Fixed at 4 images; do not send n; data holds 4 URLs | Same as Seedream | Not supported yet | resolution, negative_prompt |
Editing and image-to-image
Models whose name contains edit or i2i (for example qwen-image-edit-plus, wan2.6-i2i) only edit an existing image and require images; without it the request is rejected before submission (400) and nothing is charged. On other models, images turns the request into image-to-image / reference-to-image.
curl https://api.novapi.ai/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-edit-plus",
"prompt": "Replace the background with a snowy mountain at sunrise",
"images": ["https://example.com/input.jpg"]
}'gpt-image and other models
gpt-image-* still goes to the original synchronous handler by default, unchanged: it is OpenAI compatible, n, size and so on are forwarded to the provider, and the answer carries data[].url or b64_json (no id or status).
With "async": true (or Prefer: respond-async) in the request, gpt-image-* becomes an asynchronous task on the sora channel: one image per request, size and quality are passed to the channel as is, reference images go in images, the task object above is returned and you poll with GET.
Any other model id that is not in "Model families" is still forwarded unchanged by the original handler: if model is omitted the server uses dall-e-2, model and prompt are the core fields, the rest are forwarded to the provider, and the answer is the provider's OpenAI-style result, normally data[] entries with a url or b64_json. Returned URLs may be re-hosted on our CDN.
curl https://api.novapi.ai/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A watercolor illustration of a quiet seaside town",
"size": "1536x1024",
"quality": "high",
"async": true
}'
# without "async": true this request goes to the synchronous OpenAI Images route
# and answers { "created": <unix-seconds>, "data": [{ "url": "https://..." }] }Billing and failures
Billing is identical to the older /api/cqt/generator/{channel}: before submission the price per image times n is checked against your balance and pre-deducted, and it is refunded automatically if the task fails. Prices are on "Models & pricing".
A synchronous request that times out becomes a 202 and you simply poll for the result: the task is not submitted twice and not charged twice.
Errors
Errors use the OpenAI format: { "error": { "message", "type", "param", "code" } }. Branch on the status code and error.code.
| Status | code | When |
|---|---|---|
| 400 | invalid_request | Validation failed: n above the model limit, missing prompt, a malformed size, images that are not http(s) URLs, an edit / i2i model without a reference image, response_format other than url, and so on. The reason is in message; rejected before submission, nothing is charged. |
| 400 | content_policy_violation | The prompt or inputs were blocked by content rules. |
| 401 | invalid_api_key | The key is missing or invalid. |
| 402 | insufficient_quota | Insufficient balance. |
| 403 | model_not_allowed | The model is not on the key allowlist. |
| 404 | model_not_found, not_found | Not a supported model; or the task id does not exist or belongs to another account. |
| 429 | task_limit_reached | The concurrent task limit was reached. |
| 502 | image_generation_failed | The task failed during a synchronous request; for an asynchronous task GET returns status: failed with the same error.code. |