Skip to main content
POST

Model selection

Both models offer the same output dimensions and image quality. Choose the official version for multiple images in one request, or Ext for per-image cost estimates. Refer to model pricing for current prices.
This is an asynchronous endpoint. A successful submission returns a task_id. Use task queries to retrieve status and images. Poll every 3–5 seconds and allow at least 3 minutes for the overall wait timeout.

Request headers

string
required
Bearer authentication in the format Bearer <token>, where <token> is your APIMart API Key.

Request parameters

string
required
Model ID: gemini-nano-banana-2.1 or gemini-nano-banana-2.1-ext.
string
required
A text description for image generation or editing. Chinese and English are supported.
string
default:"auto"
Output aspect ratio. Supports 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, and 21:9. Formats such as 16x9 are also accepted.If omitted or set to auto, the model decides. Image-to-image output follows the reference image aspect ratio.Other ratios, including 1:4, 4:1, 1:8, and 8:1, are not supported. Unsupported ratios cause task failure and a refund.
string
default:"1K"
Output resolution tier: 1K, 2K, or 4K. Lowercase values are accepted. This also affects billing.0.5K and 512 are not supported and return HTTP 400 on submission. Other unrecognized values, such as 3K, use 1K for both generation and billing. Use only the supported values above.
integer
default:"1"
Number of output images: 1–4 for the official version; only 1 for Ext.Values above 4 return HTTP 400 immediately. Ext requests with 2–4 fail during execution and receive a full refund. Submit separate Ext tasks or use the official version for multiple images.
string[]
Reference image list. Omit for text-to-image; provide for image-to-image or editing. Each item supports:
  • A publicly accessible HTTP(S) image URL.
  • A Base64 Data URL, such as data:image/png;base64,....
PNG, JPEG, or WEBP is recommended. The official version allows up to 20MB per image. Ext allows up to 20MB per image and 50MB in total.The platform has no fixed reference image count limit, but uploads are not unlimited: exceeding model limits may cause task failure and a refund. More reference images usually take longer.
boolean
default:"false"
Only applies to gemini-nano-banana-2.1-ext. When enabled, attempts to complete the task using the official version if Ext fails.If the official version is actually used, billing switches to its actual token usage instead of Ext per-image pricing.
string
Callback URL notified when the task ends. See task webhooks.

Output dimension reference

These dimensions include measured values and reference values from the model family. Not all combinations have been tested. The actual returned image determines the pixel dimensions.

Edit a reference image

Replace the example URL with an accessible image URL. If size is omitted, output follows the reference image aspect ratio.

Batch generation (official version only)

Submission response

integer
Response status code. 200 indicates success.
array
Task submission result. status is submitted. Use task_id to query task status and results; it is not the final image URL.

Query task results

Example success response (the image URL is a placeholder):
All finished image links are in the data.result.images[0].url array. Generating 4 images gives 4 links in this array. Only finished images are returned; n=1 corresponds to 1 finished image. Links expire 24 hours after task completion, as indicated by expires_at. Download and save them promptly. Output is PNG or JPEG; refer to the actual file content. data.cost in the query result is the final charge in USD.

Billing

  • Official version: billed by actual input and output token usage. Prompts and reference images count as input. An amount based on resolution tier and n is reserved at submission, then adjusted to actual usage with a refund or additional charge.
  • Ext version: resolution-tier unit price × actual image count. Aspect ratio does not affect the tier. If official_fallback is enabled and the official version is actually used, official token-based billing applies.
  • Refer to model pricing for unit prices. Requests rejected at submission create no task and incur no charge. Failed tasks receive a full refund.

Common errors

Nano banana 2.1 and Gemini 3.1 Flash Image are different models; their names are not interchangeable aliases. When migrating from the latter, remove 0.5K resolution and the four extreme ratios: 1:4, 4:1, 1:8, and 8:1.