API429 / API reference

Image generation through API429

Image generation on API429: Google Nano Banana and GPT Image models, /v1/images/generations, request fields, examples and the response format.

Reference version 3.31.0 · revised · the same text in the client portal

Google image models (Nano Banana family)

Model Friendly name / compatibility alias Generate Edit / references Resolution
gemini-nano-banana-2.1 Nano Banana 2.1 yes yes 1K, 2K
gemini-3.1-flash-image Nano Banana 2 (nano-banana-2) yes yes 1K, 2K
gemini-3-pro-image Nano Banana Pro (nano-banana-pro) yes yes 1K, 2K
gemini-3.1-flash-lite-image Nano Banana 2 Lite (nano-banana-2-lite) yes — (generation only) 1K

Use POST /v1/images/generations (OpenAI-compatible) or the Gemini-native generateContent route described below. Aliases are accepted for existing integrations. gemini-3.1-flash-image, nano-banana-2 and generic nano-banana can resolve to the current Nano Banana 2.1 route. This is a gateway compatibility contract, not proof of historical upstream identity, including Gemini 2.5 Flash Image. Use gemini-nano-banana-2.1 for new integrations; look up the requested ID's price in the catalog rather than inferring it from the alias name.

Image-edit endpoints differ. The edit/reference support in the table above refers to JSON image input on /v1/images/generations; it is not a promise that every listed ID accepts multipart /v1/images/edits. For the exact gemini-nano-banana-2.1 ID, a multipart request without mask currently returns 400 before native generation. A request with mask selects a separate Codex image path, not native Nano editing; do not add a mask as a workaround. Keep the JSON and multipart contracts separate and select a model explicitly supported by the endpoint you use.

Field Values Notes
prompt string Required.
n 1–4 Number of images in one request (default 1).
aspect_ratio 1:1, 16:9, 9:16, 4:3, 3:4 Default 1:1. Instead of aspect_ratio you can send an OpenAI size: 1024x1024 → 1:1, 1792x1024 → 16:9, 1024x1792 → 9:16; another WIDTHxHEIGHT uses the nearest ratio.
resolution 1K (default), 2K Also accepted as image_size / imageSize or quality (standard = 1K, hd = 2K).
seed integer Optional, for repeatable drafts.
image string or array of strings Image editing. Each entry is an HTTPS URL, a data:image/...;base64,... URI or plain base64. The first entry is the image being edited; any further entries are reference images.
reference_images / images array Extra reference images (same formats; see "reference_images format" below).
response_format url (default) or b64_json
  • Up to 10 images in total per request (the edited image plus references).
  • gemini-3.1-flash-lite-image generates from text only; use gemini-3.1-flash-image or gemini-3-pro-image for edits and references.
  • Unsupported options are refused, not swapped. 4K is not available on these models today, and aspect ratios other than the five above are served only when capacity for them is available. Such a request returns HTTP 400 naming the supported values, for example Supported resolution values: 1K, 2K. No image was generated or charged. Retry with a supported value.
  • Reference URLs must be publicly downloadable. If the gateway cannot download a reference URL, the request returns HTTP 400 (Reference image URL could not be downloaded: ...) before anything is generated or charged. Send the image inline as base64 instead.
  • Images are billed per delivered image at the requested resolution (see the pricing table below); your account discount applies.

Generate two 16:9 images:

curl https://gateway.api429.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3.1-flash-image",
    "prompt": "A cosy reading nook with warm morning light, photorealistic",
    "n": 2,
    "aspect_ratio": "16:9",
    "resolution": "2K",
    "response_format": "url"
  }'

Edit a photo using two reference images:

curl https://gateway.api429.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3-pro-image",
    "prompt": "Put the person from the first image into the jacket from the second image, in the setting of the third image",
    "image": [
      "https://example.com/person.jpg",
      "https://example.com/jacket.png",
      "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
    ],
    "aspect_ratio": "3:4",
    "response_format": "b64_json"
  }'

The same with the OpenAI Python SDK (fields the SDK does not know go in extra_body):

import base64
from openai import OpenAI

client = OpenAI(base_url="https://gateway.api429.com/v1", api_key="YOUR_API_KEY")

result = client.images.generate(
    model="gemini-3.1-flash-image",
    prompt="Turn this sketch into a watercolor painting, keep the composition",
    n=1,
    response_format="b64_json",
    extra_body={
        "image": ["https://example.com/sketch.png"],  # first = image to edit
        "aspect_ratio": "4:3",
        "resolution": "1K",
        "seed": 42,
    },
)
with open("watercolor.png", "wb") as f:
    f.write(base64.b64decode(result.data[0].b64_json))

Nano Banana 2 native image requests

For gemini-3.1-flash-image and its -preview alias, non-streaming generateContent requests with one user turn and responseModalities including IMAGE return Gemini JSON (candidates[].content.parts[].inlineData). For one-image requests, use supported dimensions and inline PNG, JPEG or WebP references with an explicit output aspect ratio (up to 10 references, at most 5 MiB each). Returned token counts may be estimates; image charges use the delivered image count and requested resolution. After an uncertain image submission or accepted task, API429 does not automatically create a second paid image. If capacity is unavailable, retry according to the returned HTTP status and Retry-After header.

Available Models

Model Status Cost per Image Notes
gpt-image-2 Stable $0.005-$0.211 output image estimate + input tokens GPT Image; exact price depends on text/image input, quality, and size
gpt-image-2.5-flare Stable $0.053 GPT Image 2.5, fast mode. Fixed price per image; see "GPT Image 2.5".
gpt-image-2.5-sunburst Stable $0.211 GPT Image 2.5, thinking mode. Fixed price per image; see "GPT Image 2.5".
gemini-2.5-flash-image (Nano Banana) Stable $0.039 Legacy Google image model.
gemini-3.1-flash-lite-image (Nano Banana 2 Lite) Stable $0.0336 Fast 1K image generation.
imagen-4 Stable $0.040 Imagen 4
gpt-image-1 (Sora Images) Stable $0.040 Compatibility name: sora-images; up to 4 per call via n.
grok-imagine-image Stable $0.020 (1K/2K) Native xAI Images API ; text-to-image
grok-imagine-image-quality Stable $0.050 (1K), $0.070 (2K) Native xAI quality image model; compatibility alias: grok-image.
gemini-nano-banana-2.1 (Nano Banana 2.1) Stable $0.0336 Newest Nano Banana (Google GA 2026-10-06); 1K/2K, generation and editing. Nano Banana 2 compatibility names can resolve to this route; see the alias contract.
gemini-3.1-flash-image (Nano Banana 2) Stable $0.067 1K/2K output, balanced speed/quality.
gemini-3-pro-image (Nano Banana Pro) Stable $0.134 High visual fidelity for edits; 1K/2K.
api429-image Stable $0.040 api429 image: image generation and editing.
FLUX.2-pro Stable $0.030+ Azure AI Foundry / Black Forest Labs FLUX.2 pro. Billed by generated megapixels and reference-image megapixels (1 MP = 1024×1024).
dalle-3 Stable $0.040 DALL·E 3 (variants: dalle-3-openai, dalle-3-bing). Bing channel accepts 4:7 / 7:4 aspect ratios.
midjourney-7.0-fast Stable $0.021 Midjourney v7 fast tier; 4-image batch, billed per job. Also: midjourney-7.0-relax ($0.011); midjourney-6.1-*, midjourney-8.1-*
flux-1 Stable $0.040 Flux.1 generations; width/height 600–1600 px, copies 1–2
qwen-image Stable $0.040 Qwen text-to-image; supports width/height, style, n=1..2
qwen-image-edit Stable $0.040 Qwen edit with reference image. Subtypes (same price): qwen-image-remove-bg, -remove-watermark, -restore, -colorize-1, -colorize-2, -contour, -depth, -extract-clothing, -make-old, -make-young, -stylize, -3d
acc-upper / acc-lower / acc-full Stable $0.060 AI Change Clothes (upper / lower / full body). Needs person photo in image + clothing reference in images[0]

Use the technical IDs above in new integrations. Existing nano-banana, nano-banana-2, nano-banana-2-lite, and nano-banana-pro requests remain accepted for compatibility; they are not separate models. Retired -preview IDs and legacy spelling aliases also remain compatibility inputs where supported. The public website hides duplicate aliases only when their canonical model is published. Check the runtime catalog for current availability. api429-image (api429 image) supports image generation and editing.

Gemini image resolution pricing:

Canonical model 1K official / API429 standard* 2K official / API429 standard*
gemini-nano-banana-2.1 (Nano Banana 2.1) $0.0336 / $0.0101 $0.0504 / $0.0151
gemini-3.1-flash-image (Nano Banana 2) $0.067 / $0.0201 $0.101 / $0.0303
gemini-3-pro-image (Nano Banana Pro) $0.134 / $0.0402 $0.134 / $0.0402

* API429 standard amounts apply the standard 70% client discount. A per-client billing profile may override that discount.

All image models are exposed on the same /v1/images/generations endpoint. No extra credentials are needed on the client side. For model:"gpt-image-2", the request uses the dedicated GPT Image route, not the Gemini image model family.

Resolution tiers. The rates in the main model table are 1K rates unless a row says otherwise. Nano Banana 2.1 is $0.0336 / $0.0504 at 1K / 2K, Nano Banana 2 is $0.067 / $0.101 and Nano Banana Pro $0.134 / $0.134; 4K is not available on these models. imagen-4 has Fast / Standard / Ultra tiers ($0.02 / $0.04 / $0.06). FLUX.2-pro uses Azure FLUX megapixel billing: first generated MP is $0.030, each additional generated MP is $0.015, and each reference-image MP is $0.015. xAI grok-imagine-image costs $0.020 at either 1K or 2K; grok-imagine-image-quality costs $0.050 at 1K and $0.070 at 2K. Pick aspect_ratio / size accordingly.

Grok image limits. For HTTP 429 responses, follow Retry-After and use bounded retries with backoff.

Example:

curl https://gateway.api429.com/v1/images/generations \
  -H "Authorization: Bearer $API429_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-image-quality",
    "prompt": "Editorial product photo on a clean studio background",
    "resolution": "2K",
    "aspect_ratio": "16:9",
    "response_format": "url"
  }'

The xAI image API currently supports text-to-image at 1K or 2K. It rejects 4K, reference images, masks, negative_prompt, style, and seed explicitly instead of silently dropping them. Use a model documented for image editing when reference-image fidelity is required.

Output format note: the gateway preserves the MIME type of the bytes the provider actually returned; it does not label every image .png. With response_format:"url", every item has a url: normally a hosted URL, or a data:<actual-mime>;base64,… URL if the uploader is unavailable or fails. With response_format:"b64_json", every item has raw standard base64 in b64_json. PNG, JPEG, and WebP are all possible when supported upstream.

Endpoint

POST /v1/images/generations

Request Body

Field Type Required Default Description
model string No nano-banana Model ID from table above (the default when omitted)
prompt string Yes — Text description of the image
n integer No 1 Number of images (1–8). Google Nano Banana models: 1–4. Some models always return 1 regardless.
size string No 1024x1024 Image dimensions, used for the shape: 1536x1024 → 3:2, 1024x1536 → 2:3, 1792x1024 → 16:9, 1024x1792 → 9:16; any other WIDTHxHEIGHT uses the nearest supported aspect ratio. aspect_ratio overrides it.
aspect_ratio string No — 1:1, 16:9, 9:16, 4:3, 3:4
resolution string No 1K Output tier: 1K (default), 2K, 4K. Aliases: standard, hd, ultra. Also accepts image_size / imageSize. Google Nano Banana models: 1K / 2K only (4K returns 400).
quality string No — OpenAI-style tier: standard → 1K, hd → 2K, ultra → 4K.
image_config object No — Nested Google image configuration. Accepts snake_case or camelCase forms of image_size, aspect_ratio, negative_prompt, output_mime_type, and person_generation. Also accepts imageConfig. Top-level wins when both forms are supplied; a non-object returns 422. Supplying outputMimeType or personGeneration makes the request Vertex-only.
response_format string No url url or b64_json
outputMimeType / output_mime_type string No Provider default Requested Google output MIME: image/png, image/jpeg, or image/webp. The response reports the MIME actually returned.
personGeneration / person_generation string No Provider default Google person-generation policy: ALLOW_ALL, ALLOW_ADULT, ALLOW_NONE, or equivalent Imagen spelling DONT_ALLOW. The gateway translates the deny value for the selected Google model family .
background string No — For gpt-image-2, use opaque or auto. Transparency requires separately verified provider support.
output_format string No png For gpt-image-2: png, jpeg, or webp when honored upstream.
output_compression integer No — For jpeg / webp, 0-100 when honored upstream.
moderation string No auto For GPT Image compatibility: auto or low.
image string or array No — Image to edit (base64, URL, or data URI). For Google models a list is accepted: the first entry is edited, the rest are references.
reference_images array No — Multiple reference images — see format below
negative_prompt string No — What to avoid

Google image controls. outputMimeType and personGeneration may be supplied at the top level or inside imageConfig. If a requested control is unavailable, the request fails with HTTP 503 rather than silently dropping the field. Requests for non-Google image models fail with HTTP 400 when these Google-specific controls are supplied.

Requesting 2K output

All three of these are equivalent:

{"model": "gemini-3-pro-image", "prompt": "...", "resolution": "2K"}
{"model": "gemini-3-pro-image", "prompt": "...", "image_size": "2K"}
{
  "model": "gemini-3-pro-image",
  "prompt": "...",
  "image_config": {"image_size": "2K", "aspect_ratio": "16:9"}
}

Using the OpenAI SDK:

client.images.generate(
    model="gemini-3-pro-image",
    prompt="...",
    extra_body={"image_size": "2K"},
)

Model support by resolution:

Model 1K 2K 4K Source
gemini-nano-banana-2.1 (Nano Banana 2.1) ✅ ✅ — (400) Google GA 2026-10-06
gemini-3-pro-image (Nano Banana Pro) ✅ ✅ — (400) ai.google.dev
gemini-3.1-flash-lite-image (Nano Banana 2 Lite) ✅ — — ai.google.dev
gemini-3.1-flash-image (Nano Banana 2) ✅ ✅ — (400) ai.google.dev — gemini-3.1 flash-image
gemini-2.5-flash-image (Nano Banana) ✅ — — legacy; Google lists shutdown no earlier than 2026-10-02
imagen-4 ✅ ✅ — Imagen 4 / Imagen 4 Ultra cap at 2048×2048
FLUX.2-pro yes yes yes Azure FLUX.2 pro; billed by rounded-up generated/reference MP
grok-imagine-image yes yes — Native xAI Images API; text-to-image
grok-imagine-image-quality / grok-image yes yes — Native xAI quality model; grok-image is the compatibility alias
  • The balancer forwards the requested tier to the selected image model. If a model does not support the requested tier, the upstream may return HTTP 400. We do not silently downgrade between tiers the model understands.
  • Non-Google image models may use different native size primitives; see the caveats below.

Compatibility notes for non-Google models:

  • FLUX.2-pro accepts either explicit pixel-shaped size (for example "1024x1024", "2048x2048") or resolution / image_size / quality tiers. quality:"standard" maps to 1K, quality:"hd" maps to 2K, and quality:"ultra" maps to 4K. aspect_ratio is used when deriving dimensions from a tier.
  • Other non-Google image providers may use different native size primitives.

Google Nano Banana models (gemini-nano-banana-2.1, gemini-3.1-flash-image, gemini-3-pro-image) serve 1K and 2K today. A 4K request for them returns 400 listing the supported resolutions (1K, 2K), and nothing is charged (see "Google image models (Nano Banana family)").

Azure FLUX.2-pro references and billing

FLUX.2-pro supports up to 8 reference images on the JSON image-generation endpoint. References may be supplied through reference_images, or through OpenAI-compatible image / images fields. Extra references above 8 are ignored after the first 8.

Billing is based on rounded-up megapixels:

  • generated output: first MP $0.030, each additional MP $0.015;
  • each reference image: $0.015 per rounded-up MP;
  • 1 MP is treated as 1024x1024 pixels.

Example with two references:

{
  "model": "FLUX.2-pro",
  "prompt": "Create a premium studio product image using the references",
  "quality": "hd",
  "aspect_ratio": "16:9",
  "reference_images": [
    {"image_url": "https://cdn.example.com/ref-1.png"},
    {"image_base64": "data:image/jpeg;base64,..."}
  ],
  "n": 1,
  "response_format": "url"
}

Image editing (reference images + edit prompt)

For edit/reference-image workflows, prefer gemini-3-pro-image when visual fidelity to the input image is critical. Flash image models remain suitable for fresh generations and lower-cost drafts, but Pro is the safer choice for production edits.

If you want Pro explicitly from the caller side, pin model: "gemini-3-pro-image". The older names remain input aliases only.

reference_images format

Accepts either structured objects or bare URL strings in the same array:

{
  "reference_images": [
    "https://cdn.example.com/ref_1.jpg",
    {
      "name": "ref_2",
      "image_base64": "<base64-without-data-uri-prefix>",
      "mime_type": "image/png"
    },
    {
      "image_url": "https://cdn.example.com/ref_3.webp"
    }
  ]
}
  • A bare string is treated as {"image_url": "<string>"} — the server fetches the URL and base64-encodes it at provider boundary.
  • Object form requires at least one of image_base64 / image_url. name and mime_type are optional.
  • Base64 inputs may use standard base64 or URL-safe base64, with or without padding. API429 validates the bytes and canonicalizes forwarded/output base64 to padded standard base64 (+, /, =), so a gateway response can be sent back unchanged in a later edit request.
  • The default image_url fetch timeout is 30s. A failed fetch returns HTTP 400 with the underlying error message.

Examples

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    base_url="https://gateway.api429.com/v1",
    api_key="YOUR_API_KEY"
)

response = client.images.generate(
    model="gemini-2.5-flash-image",
    prompt="A futuristic city at sunset, cyberpunk style",
    n=1,
    size="1024x1024"
)

print(response.data[0].url)

Python (FLUX)

response = client.images.generate(
    model="FLUX.2-pro",
    prompt="Product photography of a ceramic teapot, studio light",
    n=1,
    quality="hd",
    extra_body={
        "aspect_ratio": "16:9",
        "reference_images": [
            {"image_url": "https://cdn.example.com/ref-1.png"},
        ],
    },
)
print(response.data[0].url)

Python (Base64 Response)

response = client.images.generate(
    model="gemini-3-pro-image",
    prompt="A cute robot reading a book",
    n=1,
    size="1024x1024",
    response_format="b64_json"
)

import base64
image_data = base64.b64decode(response.data[0].b64_json)
with open("robot.png", "wb") as f:
    f.write(image_data)

cURL

curl https://gateway.api429.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-2.5-flash-image",
    "prompt": "A mountain landscape at sunrise",
    "n": 1,
    "size": "1024x1024"
  }'

Response Format

{
  "created": 1712345678,
  "data": [
    {
      "url": "https://storage.googleapis.com/generated/...",
      "revised_prompt": "A futuristic city at sunset, cyberpunk style"
    }
  ]
}

With response_format: "b64_json":

{
  "created": 1712345678,
  "data": [
    {
      "b64_json": "/9j/4AAQSkZJRgABAQ...",
      "revised_prompt": "A futuristic city at sunset"
    }
  ]
}

With response_format: "url", the response always uses the url field. If object storage upload is unavailable or fails, the value is a valid data URI using the actual returned MIME type; the gateway does not silently switch the field to b64_json.

Quickstart: the first request · Models and prices · Get an API key

Telegram