APIMaster.ai

Nano Banana 2.1 API — Text-to-image and reference editing

Generate and edit images with gemini-nano-banana-2.1, including 1K/2K/4K base prices and billing.

Nano Banana 2.1 Image API

Model ID: gemini-nano-banana-2.1. Generate images from text or edit reference images at 1K, 2K or 4K, with one image per request.

Use the Images API. Direct /v1/chat/completions requests are rejected. Image requests do not support stream=true; n must be 1. Masks are currently unsupported.

Text-to-image

Send JSON to POST https://apimaster.ai/v1/images/generations.

curl --max-time 300 "https://apimaster.ai/v1/images/generations" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-nano-banana-2.1",
    "prompt": "A lavender ceramic teapot beside two green pears, white background",
    "size": "1:1",
    "resolution": "1K",
    "n": 1,
    "response_format": "url"
  }'

Reference image editing

Upload the actual reference file using multipart/form-data to POST https://apimaster.ai/v1/images/edits. Let cURL set the multipart Content-Type and boundary.

curl --max-time 300 "https://apimaster.ai/v1/images/edits" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "model=gemini-nano-banana-2.1" \
  -F "prompt=Keep all foreground objects and lettering. Change only the background to mint green." \
  -F "image=@reference.png" \
  -F "size=1:1" \
  -F "resolution=2K" \
  -F "n=1" \
  -F "response_format=url"

Alternatively, send image_urls in a JSON /images/generations request. Each item can be a public image URL or a complete data:image/png;base64,... URI. Up to 14 references are accepted; mentioning a reference in the prompt does not upload it.

{
  "model": "gemini-nano-banana-2.1",
  "prompt": "Preserve the subject and lettering; change the background to mint green.",
  "image_urls": ["https://example.com/reference.png"],
  "size": "1:1",
  "resolution": "2K",
  "n": 1
}

Parameters

Field Description
model Required; gemini-nano-banana-2.1
prompt Required; scene description or editing instructions
resolution 1K, 2K or 4K; pass explicitly, defaults to 1K
size Aspect ratio, default 1:1; pixel dimensions that reduce to a supported ratio, such as 1024x1024, are also accepted
n Only 1
response_format url or b64_json
image Multipart reference file for /images/edits
image_urls JSON reference array for /images/generations

Supported aspect ratios: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 4:1, 1:8, 8:1.

Explicit resolution determines the output and billing tier; size determines the aspect ratio. For example, size=1024x1024 with resolution=4K requests a square 4K image.

Image pricing and billing

Base prices verified on October 7, 2026, in USD per image, not per thousand images:

Resolution Base price Tested default-group price (1.05 multiplier)
1K $0.0336 $0.03528
2K $0.0504 $0.05292
4K $0.0756 $0.07938

User price = resolution base price × channel group multiplier × recharge multiplier × model/APIMaster multiplier × user group multiplier × actual returned image count, rounded to platform quota precision. The example uses channel 38, whose channel, recharge and model multipliers are all 1. Other routes or user groups may differ; check the marketplace and usage logs. Both generation and editing use image pricing; channel token prices do not replace these base prices.

Response and usage logs

{
  "created": 1791339727,
  "data": [{"url": "https://apimaster.ai/imgs/IMAGE_ID.png"}]
}

With response_format=b64_json, decode data[0].b64_json to save the image. Download or copy temporary image URLs promptly. Logs record result_url, actual image count and request_data.effective_resolution, with thumbnails and a full-image preview.

Production tests returned 1024×1024, 2048×2048 and 4096×4096 images. The 2K reference edit preserved the shapes, colors and lettering while changing the background.

Operational notes

  • Create an API key in the console and authenticate with Authorization: Bearer YOUR_API_KEY.
  • A 300-second HTTP read timeout is recommended for high-resolution generation.
  • Invalid parameters, keys, insufficient balance, rate limits and upstream failures return errors. A response with no generated image is not settled as a successful image.
  • Reference images must be readable by the upstream; uploads or data URIs avoid inaccessible public URLs.