API guide

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.

statusMeaning
queuedAccepted, not started.
in_progressGenerating.
completedDone. data[].url holds the image URL (several when n is above 1).
failederror.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.message

Python (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

FieldDescription
modelRequired; see "Model families" below.
promptRequired; the image description.
nNumber of images, default 1; the upper limit depends on the model family (see the table). Above it the call returns 400.
sizeWIDTHxHEIGHT, 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_ratioSet the aspect ratio directly, for example 16:9; it wins when size is also sent.
resolution1K / 2K / 4K, for nano, gemini and the Tencent-backed models; the tiers you can pick depend on the model.
imagesReference image URLs, a string or an array; image and image_urls work too. http(s) URLs only, no base64.
output_formatpng, jpeg, ... for nano, gemini and flux only.
negative_prompt, prompt_extendnegative_prompt is for qwen / Wan and the Tencent-backed models; prompt_extend (boolean) is for qwen / Wan only.
qualitylow / medium / high / auto, for gpt-image in asynchronous mode only; passed to the channel as is.
asynctrue: answer 202 with the task object right away, then poll with GET; the Prefer: respond-async header works too. Synchronous by default.
response_formatFor the models behind this facade it can only be url; any other value returns 400.
Native channel fieldsNative 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` / ratioReference imagesOther fields
Nano Banananano-banana, nano-banana-pro, nano-banana-2, nano-banana-2.11-4Converted 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 worksimagesresolution, output_format
Gemini imagegemini-3-pro-image-preview, gemini-3.1-flash-image-preview1-4Same as Nano Bananaimagesresolution, output_format
FLUX Kontextflux-kontext-pro, flux-kontext-maxExactly 1Nearest of 21:9, 16:9, 3:2, 4:3, 1:1, 3:4, 2:3, 9:16; default 1:1imagesoutput_format. Availability follows the model marketplace
Qwen / Wanqwen-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-4Nearest of 16:9, 4:3, 1:1, 3:4, 9:16; default 1:1images; required for edit / i2i modelsnegative_prompt, prompt_extend
GPT-Imagegpt-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-sunburstSynchronous by default, handled by the original handler; exactly 1 with async: truesize and quality are passed to the channel as isUse images in asynchronous modeSee "gpt-image and other models"
Seedreamseedream-5.0-pro, seedream-5.0-lite, seedream-4.5, seedream-4.0Up to 4Nearest of 16:9, 3:2, 4:3, 1:1, 3:4, 2:3, 9:16; aspect_ratio is validated by the channelimagesresolution, negative_prompt
Kling imagekling-image-3.0, kling-image-3.0-omni, kling-image-o1, kling-image-2.1Up to 9Same as Seedreamimagesresolution, negative_prompt
Vidu, Hunyuan, Mingmou imagevidu-image-q2, hunyuan-image-3.5-preview, hunyuan-image-3.0, mingmou-image-1.0Exactly 1Same as Seedreamimages; limits on each model pageresolution, negative_prompt
Midjourneymj-v8.2, mj-v8.1, mj-v7, mj-niji7Fixed at 4 images; do not send n; data holds 4 URLsSame as SeedreamNot supported yetresolution, 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.

StatuscodeWhen
400invalid_requestValidation 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.
400content_policy_violationThe prompt or inputs were blocked by content rules.
401invalid_api_keyThe key is missing or invalid.
402insufficient_quotaInsufficient balance.
403model_not_allowedThe model is not on the key allowlist.
404model_not_found, not_foundNot a supported model; or the task id does not exist or belongs to another account.
429task_limit_reachedThe concurrent task limit was reached.
502image_generation_failedThe task failed during a synchronous request; for an asynchronous task GET returns status: failed with the same error.code.

See also