Nano Banana Pro — enhanced image creation and resolution.Try it now →
Developer API · Nano Banana 2.1

Nano Banana 2.1 API

Generate and edit images with Google's Nano Banana 2.1 model straight from your code. One REST endpoint, Bearer API keys, text-to-image and image-to-image, and 1K/2K/4K output — billed with the same credits as the website.

cURL
curl -X POST https://aibanana.net/api/v1/images \
  -H "Authorization: Bearer ban_sk_live_xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "a red panda barista in a cozy cafe, studio light",
    "resolution": "2K",
    "num_images": 1,
    "aspect_ratio": "1:1"
  }'

Quickstart

Create a key in your dashboard, then send one POST request. The response includes the generated image URLs and your remaining credits.

JavaScript (fetch)
const res = await fetch("https://aibanana.net/api/v1/images", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.AIBANANA_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    prompt: "product shot of a glass perfume bottle on marble",
    image_urls: ["https://example.com/reference.jpg"], // optional -> image-to-image
    resolution: "4K",
    num_images: 1,
    aspect_ratio: "4:5",
    output_format: "png",
  }),
});

const data = await res.json();
console.log(data.images[0].url);
Response
{
  "model": "nano-banana-2-1",
  "mode": "text-to-image",
  "resolution": "2K",
  "images": [
    { "url": "https://cdn.aibanana.net/...", "width": 2048, "height": 2048 }
  ],
  "credits_used": 1,
  "credits_remaining": 499
}

Endpoint

POSThttps://aibanana.net/api/v1/images

Authenticate with Authorization: Bearer ban_sk_live_.... Send a JSON body with these fields:

FieldTypeDescription
promptstring (required)Text description of the image to generate.
image_urlsstring[] (optional)Up to 14 reference image URLs. If present, the request runs image-to-image.
resolution"1K" | "2K" | "4K"Output resolution. Defaults to "1K".
num_imagesinteger 1–4How many images to generate. Defaults to 1.
aspect_ratiostringe.g. "auto", "1:1", "16:9", "9:16", "4:5", "21:9". Defaults to "auto".
output_format"jpeg" | "png"Image encoding. Defaults to "jpeg".

Errors

401 unauthorizedMissing or invalid API key.
402 insufficient_creditsNot enough credits on the account. Top up at /price.
400 invalid_requestMalformed JSON or missing "prompt".
429 rate_limitedMore than 20 requests/minute per key. Respect Retry-After.
502 generation_failedThe model failed. Credits for the request are refunded automatically.

Why the Nano Banana 2.1 API

One REST endpoint

A single POST to /api/v1/images. No SDK required — works from any language that can send HTTP.

Bearer API keys

Create and revoke keys in your dashboard. Keys are stored hashed; the plaintext is shown once.

Text & image to image

Send a prompt for text-to-image, or add up to 14 reference images for edits and character consistency.

1K / 2K / 4K output

Choose resolution per request. Pick PNG or JPG and any common aspect ratio.

Credit-based billing

Pay with the same credits as the website — 1 credit per generated image. No separate contract.

Automatic refunds

If a generation fails, the reserved credits are refunded to your account automatically.

Pricing

API calls spend the same credits as the website — 1 credit per generated image, any resolution. Buy credits once and use them in the app or via the API.

Build with Nano Banana 2.1

Programmatic ad creatives with readable text
On-demand product mockups in your own app
Batch character edits across scenes
User-generated posters, thumbnails, and covers
Background, clothing, and pose changes via image_urls
Panoramic social and web graphics at 4K

FAQ

How do I get a Nano Banana 2.1 API key?

Sign in and open your dashboard. In the "API Keys" card, create a key — the full key is shown once, so copy it immediately. You can revoke keys at any time.

How much does the API cost?

The API uses the same credits as the website: 1 credit per generated image, at any resolution. Buy credit packs on the pricing page.

Does it support image-to-image?

Yes. Include an "image_urls" array (up to 14 reference images) and the request runs image-to-image, otherwise it runs text-to-image.

What resolutions are available?

Pass "resolution" of "1K", "2K", or "4K". You can also set "aspect_ratio" and "output_format" (jpeg or png).

What happens if a generation fails?

Credits are reserved when the request starts and refunded automatically if the model fails, so you are only billed for successful images.

Is there a rate limit?

Yes — 20 requests per minute per key. If you exceed it you get HTTP 429 with a Retry-After header.

Start building with Nano Banana 2.1

Create an API key, send one request, and get image URLs back. No SDK, no contract — just credits.