Developer API

Generate images and videos from your own code with a REST API and an API key.

The Nano Banana REST API lets your code and agents generate images and videos with the same models, prices and credits as the website.

Quick start

Create an API key in your account settings. The key is shown only once, so store it somewhere safe. Manage API keys

Send a generation request, then poll the returned task until it finishes.

curl
curl -X POST https://nanobanana0.com/api/v1/images \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "a lighthouse at dawn", "dry_run": true}'

Authentication

Send the key in the Authorization header as a Bearer token. Keys start with nb0_. Never put a key in client-side code or a public repository; delete it in settings if it leaks.

HTTP
Authorization: Bearer nb0_...

Each key allows 60 requests per minute, and an account can hold up to 10 keys. Over the limit the API answers 429 with a Retry-After header.

Endpoints

https://nanobanana0.com/api/v1

MethodPathDescription
POST/imagesStart an image generation. Returns 202 with a task.
POST/videosStart a video generation. Returns 202 with a task.
GET/tasks/{id}Status and outputs of a task.
GET/modelsModels with their parameters and credit prices.
GET/creditsYour credit balance.

Request body

FieldDetails
promptRequired. What to generate, up to 4000 characters.
modelModel id from /models. Omit it to use the default model.
paramsModel parameters such as aspect_ratio, as listed for the model in /models.
countNumber of outputs, within the range the model allows.
reference_idsIDs of reference images already uploaded to your account, up to 16.
modeInput mode: text, image or reference. Inferred from the inputs when omitted.
dry_runWhen true, validates and prices the request without charging credits or starting a task.

Examples

Generate an image

curl
curl -X POST https://nanobanana0.com/api/v1/images \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "a lighthouse at dawn", "params": {"aspect_ratio": "16:9"}}'

Poll the task

curl
curl https://nanobanana0.com/api/v1/tasks/TASK_ID \
  -H "Authorization: Bearer $API_KEY"
JSON
{
  "id": "TASK_ID",
  "object": "task",
  "status": "succeeded",
  "kind": "image",
  "credits_charged": 10,
  "credits_refunded": 0,
  "outputs": [
    { "index": 0, "status": "succeeded", "url": "https://...", "media_type": "image/png" }
  ]
}

Get a quote without spending credits

curl
curl -X POST https://nanobanana0.com/api/v1/images \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "a lighthouse at dawn", "dry_run": true}'

Task status

A task is processing until every output finishes. It then ends as succeeded, partial (some outputs failed) or failed. Credits are charged when the task starts, and credits for failed outputs are refunded. Poll every few seconds; output URLs appear as each output succeeds.

Errors

JSON
{ "error": "Not enough credits", "code": "insufficient_credits" }
HTTP statusCodeMeaning
400invalid_request, model_unavailableThe request is invalid, or the model is not available.
401unauthorizedThe API key is missing, wrong or deleted.
402insufficient_creditsNot enough credits for this request.
403forbiddenThe account cannot use this resource, or is suspended.
404not_foundThe task or resource does not exist.
429rate_limitedToo many requests. Wait for the Retry-After seconds.
502upstream_unavailableThe generation provider is temporarily unavailable. Try again later.
500internal_errorUnexpected server error. Try again later.

For AI agents

AI assistants can use Nano Banana through the MCP server, or read the Skill file to learn how to call this API.

MCP server setupDownload SKILL.md