English
  • 中文
  • English
English
  • 中文
  • English
官网
服务状态
English
  • 中文
  • English
  1. Images
  • Quickstart & Conventions
  • Images
    • GPT Image 2 / 2.5 / 2.6 Generation & Editing
    • Nano Banana Image Generation
    • Gemini Native Sync Image Generation
    • Seedream 5.0 Pro / 5.5 Image Generation
    • Midjourney Image Generation
  • Videos
    • Seedance 2 Video Generation
    • Omni Video Generation
    • Seedance 2.5 Video Generation
    • MiniMax H3 Video Generation
    • WAN 3.0 Video Generation
    • Muse Video Generation
    • Seedance Asset Registration
    • Gemini Omni 1.2 Flash Video Generation
    • Seedance Volcengine Native Video Generation
    • MAGI-2 Video Generation
  • Text Models
    • Claude Desktop (CC Switch) Setup Guide
    • Codex in ChatGPT Desktop Setup Guide
    • Gemini Text Models (Native Format)
    • Text & Chat APIs (OpenAI / Claude)
  • Audio
    • Gemini Text-to-Speech (TTS)
  1. Images

Nano Banana Image Generation

Create text-to-image and reference-guided image generation tasks with nano-banana-2 or nano-banana-pro. Image generation runs asynchronously: submit a task, poll its status, and retrieve the generated image from images[].url once it succeeds.

Endpoints & Authentication#

Poll task status:

Supported Models#

ModelUse Cases
nano-banana-2General-purpose text-to-image, reference-guided generation, and fast image output.
nano-banana-proHigh-resolution images, product photography, complex instructions, and scenes requiring crisp text or fine detail.
Model availability depends on your API key—query GET /v1/models for the authoritative list.
gemini-3.0-pro-image and gemini-3.1-flash-image also work with this async endpoint, sharing the exact request fields and limits of nano-banana-pro and nano-banana-2, respectively. Alternatively, use Gemini Native Sync Image Generation.
For nano-banana-2.1, use Gemini Native Sync Image Generation (POST /v1beta/models/nano-banana-2.1:generateContent).
None of the image models above support /v1/chat/completions. Selecting them in a chat client will fail.

Capabilities#

ModelInputCapabilityAsset Requirements
nano-banana-2Omit image_urlsText-to-imagePrompt only.
nano-banana-2Provide image_urlsReference-guided generation1–5 public direct image URLs, applied in array order.
nano-banana-proOmit image_urlsText-to-imagePrompt only.
nano-banana-proProvide image_urlsReference-guided generation1–14 public direct image URLs, applied in array order.

Request Parameters#

ParameterTypeRequiredDefaultDescription
modelstringYes—nano-banana-2 or nano-banana-pro (also accepts gemini-3.1-flash-image or gemini-3.0-pro-image).
promptstringYes—Image generation or editing instructions. Specify subject, scene, composition, material, lighting, and color for best results.
image_urlsstring[]No—Direct HTTPS URLs to reference images. Up to 5 images for nano-banana-2; up to 14 images for nano-banana-pro. Omit this field when not using reference images.
aspect_ratiostringNo9:16nano-banana-2 supports 1:1, 16:9, 9:16, 4:3, 3:4, auto. nano-banana-pro supports 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, auto. Both models output 9:16 portrait when omitted or set to auto. Expresses a composition preference and does not guarantee strict adherence to the selected ratio.
image_sizestringNo1K1K, 2K, or 4K (uppercase K required). Defaults to 1K for both output resolution and billing when omitted.
nintegerNo1Only 1 is currently supported; omitting this field is recommended.
New integrations only need the top-level fields listed above. Do not pass chat completion parameters such as messages, temperature, top_p, or stream.

Text-to-Image Example#

Reference Image Generation Example#

Creation Response#

A successful submission returns a task ID:
{
  "images": [],
  "progress": "10%",
  "status": "SUBMITTED",
  "task_id": "task_xxxxxxxxxxxxxxxxxxxxxxxx"
}
Save task_id. A successful creation response only indicates that the task has entered processing, not that the image has been generated.

Polling Task Status#

Poll every 3–5 seconds.
StatusAction
SUBMITTEDTask submitted; continue polling.
IN_PROGRESSGenerating image; continue polling.
SUCCESSCompleted; read images[].url.
FAILUREFailed; read fail_reason.
Stop polling once the task reaches SUCCESS or FAILURE. progress may not appear in every response—clients must not rely on it to detect terminal states.

Retrieving Results#

Example response when generation succeeds:
{
  "task_id": "task_xxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "SUCCESS",
  "progress": "100%",
  "images": [
    {
      "index": 0,
      "url": "https://example.com/result.png",
      "mime_type": "image/png"
    }
  ]
}
FieldDescription
images[].indexZero-based image index.
images[].urlImage download URL.
images[].mime_typeImage MIME type; some storage backends may return application/octet-stream.
fail_reasonFailure reason, present only when status is FAILURE. Raw diagnostic error text—do not parse against a fixed format.
Poll responses may also include auxiliary fields such as usage; clients should not depend on them.
Download the image:
Result URLs may expire—download or persist generated images promptly after the task succeeds.

Limits & Error Handling#

image_urls accepts up to 5 images for nano-banana-2 and up to 14 images for nano-banana-pro. Omit image_urls when not using reference images—do not pass an empty array.
Reference image URLs must be publicly accessible direct HTTPS image links, not web pages, preview pages, or URLs requiring authentication.
image_size only accepts 1K, 2K, or 4K. Lowercase k and other size values are not part of the public API contract.
aspect_ratio only accepts the values listed in the parameter table; unsupported ratios return a parameter error. Omitting aspect_ratio or passing auto generates a 9:16 portrait image.
aspect_ratio expresses a composition preference and does not guarantee strict adherence to the selected ratio. If your workflow requires an exact aspect ratio, validate and crop the image after generation.
Each task generates 1 image; n must be 1.
HTTP status codes: 400 invalid request parameters, 401 missing or invalid API key, 403 insufficient balance/quota or missing model permission, 404 task not found, 429 rate limit exceeded, 503 service temporarily unavailable, 500 / 502 transient server error.
Modified at 2026-12-04 09:01:17
Previous
GPT Image 2 / 2.5 / 2.6 Generation & Editing
Next
Gemini Native Sync Image Generation
Built with