Getting Started with Nano Banana API
This page will help you get started with the Nano Banana API. You will be generating, editing, and upscaling images in a few minutes.
Nano Banana API User Guide
A practical guide to understanding and using the Nano Banana API effectively.
Table of Contents
- Getting Started
- Understanding Authentication
- Choosing the Right Endpoint
- Choosing the Right Model
- Feature Guide
- Image Input Guidelines
- Response Formats
- Best Practices
- Common Use Cases
- Error Handling
- Troubleshooting
- FAQ
Getting Started
What You Need
Before you begin using the Nano Banana API, make sure you have:
- An HTTP Client - Any tool that can make HTTP requests, such as cURL, Postman, Bruno, Insomnia, or your application
- A Prompt or Source Image - Use a text prompt for generation, and an image URL, base64 image, or uploaded file for edits and upscaling
- The API Base URL - All requests should be sent to
https://nanobanana.aikit.club
First Steps
- List Available Models: Use
/v1/modelsto confirm the API is reachable - Make Your First Generation Request: Use
/v1/images/generationswith a text prompt - Try Image Editing: Use
/v1/images/editswith an existing image and edit instruction - Upscale an Image: Use
/v1/images/upscalewithx2orx4 - Display the Result: Use the returned image URL or base64 image data in your app
API Base URL
All API requests should be sent to:
https://nanobanana.aikit.clubQuick Health Check
curl https://nanobanana.aikit.club/v1/modelsExpected response:
{
"object": "list",
"data": [
{
"id": "nano-banana",
"object": "model",
"created": 1764671202,
"owned_by": "google"
},
{
"id": "imagen-4.0-upscale-preview",
"object": "model",
"created": 1764671202,
"owned_by": "google"
}
]
}Understanding Authentication
Does Nano Banana API Need an API Key?
The current public Nano Banana API OpenAPI definition does not define a required authentication scheme. The public endpoints can be called directly over HTTPS.
If you deploy your own protected version later, you can add standard bearer-token authentication:
Security Tips
- Store private deployment keys in environment variables
- Never commit secrets to version control
- Use HTTPS only
- Do not expose private API keys in browser code
- Validate authentication on your own server or worker if you add protected access
Choosing the Right Endpoint
Quick Endpoint Selector
Need to create a new image from text? Use POST /v1/images/generations.
Need a shareable or browser-testable generation URL? Use GET /v1/images/generations.
Need to modify an existing image? Use POST /v1/images/edits.
Need to edit an image that is already available at a public URL? Use GET /v1/images/edits.
Need to increase image resolution? Use POST /v1/images/upscale.
Need quick URL-based upscaling? Use GET /v1/images/upscale.
Need to verify supported model IDs? Use GET /v1/models.
Endpoint Overview
| Endpoint | Method | Description |
|---|---|---|
/v1/models | GET | Retrieve worker-supported model IDs |
/v1/images/generations | POST | Generate images from a prompt |
/v1/images/generations | GET | Generate images with query parameters |
/v1/images/edits | POST | Edit an image from a URL, base64 string, or uploaded file |
/v1/images/edits | GET | Edit an image URL with query parameters |
/v1/images/upscale | POST | Upscale an image from a URL, base64 string, or uploaded file |
/v1/images/upscale | GET | Upscale an image URL with query parameters |
/images/{filename} | GET | Serve a worker-hosted image returned by URL responses |
Choosing the Right Model
Quick Model Selector
Need image generation? Use nano-banana.
Need image editing? Use nano-banana.
Need image upscaling? Use /v1/images/upscale, which uses the worker upscale backend exposed as imagen-4.0-upscale-preview.
Model Overview
| Model | Best For | Notes |
|---|---|---|
nano-banana | Generation and editing | Generation and edit requests accept this model |
imagen-4.0-upscale-preview | Upscaling | Used through the dedicated upscale endpoint |
Feature Guide
1. Image Generation
What it does: Creates one or more images from a text prompt.
Endpoint: POST /v1/images/generations
Required fields:
prompt- Text prompt for the image, 1 to 4096 characters
Optional fields:
model- Onlynano-bananan- Number of images, from1to4aspect_ratio-1:1,16:9,9:16,3:4, or4:3size- Legacy OpenAI-compatible size parameteroutput_format-jpeg,png, orwebpresponse_format-urlorb64_json
curl -X POST https://nanobanana.aikit.club/v1/images/generations \
-H "Content-Type: application/json" \
-d '{
"prompt": "A cinematic product photo of a golden banana on a marble table",
"model": "nano-banana",
"n": 1,
"aspect_ratio": "1:1",
"output_format": "png",
"response_format": "url"
}'Tips:
- Be specific about subject, style, lighting, mood, composition, and camera angle
- Use
aspect_ratiofor new integrations - Use
nup to4when you want variations - Use
webpfor smaller web assets,pngfor crisp graphics, andjpegfor photo-like output
2. Image Generation with GET
What it does: Generates images using query parameters.
Endpoint: GET /v1/images/generations
curl "https://nanobanana.aikit.club/v1/images/generations?prompt=A%20serene%20mountain%20landscape%20at%20sunset&aspect_ratio=16:9&output_format=png&response_format=url"When to use:
- Simple tests
- Browser demos
- Short prompts
When to prefer POST:
- Longer prompts
- Production apps
- File or base64 workflows
- Cleaner request bodies
3. Image Editing
What it does: Modifies an existing image using text instructions.
Endpoint: POST /v1/images/edits
Required fields:
prompt- Instruction for editing the imageimage- Image URL, data URL base64 string, raw base64 string, or uploaded file
Optional fields:
model- Onlynano-bananan- Number of edited images, from1to4aspect_ratio-1:1,16:9,9:16,3:4, or4:3size- Legacy OpenAI-compatible size parameterresponse_format-urlorb64_json
curl -X POST https://nanobanana.aikit.club/v1/images/edits \
-H "Content-Type: application/json" \
-d '{
"prompt": "Add soft golden sunset lighting and a rainbow in the sky",
"image": "https://example.com/image.png",
"model": "nano-banana",
"n": 1,
"aspect_ratio": "1:1",
"response_format": "url"
}'Tips:
- Give direct, specific edit instructions
- Use one major edit per request when precision matters
- Use source images with visible subjects and good lighting
- Use file upload or base64 when the image is not publicly accessible
4. Image Editing with GET
What it does: Edits an image using query parameters.
Endpoint: GET /v1/images/edits
Important: GET edit requests require the image to be available as a URL.
curl "https://nanobanana.aikit.club/v1/images/edits?prompt=Add%20a%20rainbow%20in%20the%20sky&image=https%3A%2F%2Fexample.com%2Fimage.png&response_format=url"5. Image Upscaling
What it does: Increases image resolution using the worker upscale backend.
Endpoint: POST /v1/images/upscale
Required fields:
image- Image URL, data URL base64 string, raw base64 string, or uploaded file
Optional fields:
upscale_factor-x2orx4response_format-urlorb64_json
curl -X POST https://nanobanana.aikit.club/v1/images/upscale \
-H "Content-Type: application/json" \
-d '{
"image": "https://example.com/image.png",
"upscale_factor": "x4",
"response_format": "url"
}'Tips:
- Use
x2for faster enhancement - Use
x4when you need a larger final image - Upscaling works best on clean source images
- Upscale the final edited image when building a multi-step workflow
6. Image Upscaling with GET
What it does: Upscales an image URL using query parameters.
Endpoint: GET /v1/images/upscale
curl "https://nanobanana.aikit.club/v1/images/upscale?image=https%3A%2F%2Fexample.com%2Fimage.png&upscale_factor=x2&response_format=url"7. MCP Documentation Access
What it does: Allows AI tools such as Cursor, Windsurf, and Claude Desktop to access Nano Banana API documentation through a remote MCP server.
MCP URL:
https://nano-banana-api.readme.io/mcpExample configuration:
{
"mcpServers": {
"nano-banana-api": {
"url": "https://nano-banana-api.readme.io/mcp"
}
}
}Image Input Guidelines
Supported Image Inputs
For edit and upscale requests, images can be provided as:
- URL - A direct public image URL
- Data URL base64 - Example:
data:image/png;base64,... - Raw base64 - Base64 image bytes as a string
- File upload - Multipart form-data upload using the field name
image
Supported MIME Types
image/jpegimage/jpgimage/pngimage/gifimage/webpimage/bmp
GET vs POST Inputs
| Input Type | POST Edit | GET Edit | POST Upscale | GET Upscale |
|---|---|---|---|---|
| Public image URL | Supported | Supported | Supported | Supported |
| Data URL base64 | Supported | Not recommended | Supported | Not recommended |
| Raw base64 | Supported | Not recommended | Supported | Not recommended |
| File upload | Supported | Not supported | Supported | Not supported |
Aspect Ratio and Legacy Size
Nano Banana prefers aspect_ratio, but the API also accepts OpenAI-compatible size values.
Legacy size | Recommended aspect_ratio |
|---|---|
1024x1024 | 1:1 |
1792x1024 | 16:9 |
1024x1792 | 9:16 |
768x1024 | 3:4 |
1024x768 | 4:3 |
Response Formats
URL Response
Use response_format: "url" when you want a worker-hosted image URL.
{
"created": 1764671202,
"data": [
{
"url": "https://nanobanana.aikit.club/images/130708-24112025_abcd_generate.png",
"revised_prompt": "A serene mountain landscape at sunset"
}
]
}Base64 Response
Use response_format: "b64_json" when you want image bytes that your application can store or process directly.
{
"created": 1764671202,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAAA...",
"revised_prompt": "A serene mountain landscape at sunset"
}
]
}Choosing a Response Format
Use url when:
- You want the simplest integration
- You are displaying images in a web app
- You want a downloadable hosted image
Use b64_json when:
- You want to store images in your own storage
- You need to process image bytes immediately
- You do not want to depend on hosted image URLs
Best Practices
Prompt Writing
For generation:
- Describe the main subject first
- Add style, mood, lighting, colors, and composition
- Mention camera angle or framing when it matters
- Avoid vague prompts like
make it better
For editing:
- Use direct instructions
- Mention what should be preserved if important
- Make one major change at a time for better control
- Identify the target area when editing a specific part of the image
Request Optimization
Use POST for production:
- Cleaner payloads
- Better for long prompts
- Supports files and base64 inputs
- Easier to extend later
Use GET for quick tests:
- Easy browser testing
- Simple demos
- Short prompts
- Public image URLs
Reliability
- Validate required fields before sending requests
- Retry temporary
500and504errors with backoff - Do not retry
400errors without changing the request - Store
revised_promptif you want reproducible image history
Common Use Cases
1. Building an Image Generator
Goal: Let users create images from prompts.
Steps:
- Collect a prompt
- Let users choose aspect ratio and output format
- Call
/v1/images/generations - Display the returned image URL
- Save the image URL and revised prompt
Best practices:
- Limit prompt length to 4096 characters
- Allow up to 4 variations with
n - Show loading states
- Provide download controls
2. Building an Image Editor
Goal: Let users upload or link an image and modify it with text.
Steps:
- Accept an image URL or file upload
- Collect a clear edit instruction
- Call
/v1/images/edits - Show before and after images
- Let users continue editing the result
Best practices:
- Use multipart form-data for local uploads
- Keep edit instructions specific
- Store original and edited image URLs
- Add a before/after comparison UI
3. Building an Upscaler
Goal: Improve image resolution.
Steps:
- Accept an image URL, base64 image, or file upload
- Let users choose
x2orx4 - Call
/v1/images/upscale - Display and download the upscaled image
Best practices:
- Default to
x2 - Use
x4for final export workflows - Warn users that larger upscales can take longer
- Upscale after final edits for best workflow quality
4. OpenAI-Compatible Image Integration
Goal: Use familiar /v1/images/* endpoints in an existing app.
Steps:
- Set the base URL to
https://nanobanana.aikit.club - Use
/v1/images/generationsfor prompt-to-image - Use
/v1/images/editsfor image edits - Use
/v1/modelsto verify model IDs
Best practices:
- Prefer
aspect_ratioover legacysize - Keep
modelasnano-bananafor generate and edit - Use
response_format: "url"unless you need image bytes
Error Handling
Error Response Structure
Error responses follow this format:
{
"error": {
"message": "Missing or invalid required parameter: prompt",
"type": "invalid_request_error",
"param": null,
"code": null
}
}Common Errors and Solutions
Invalid Request (400)
Symptoms: Missing prompt, missing image, invalid parameter, or unsupported value.
Solutions:
- Check all required fields
- Use supported values for
aspect_ratio,output_format, andupscale_factor - Ensure
nis between1and4 - Use a valid public image URL for GET edit and upscale requests
Image Not Found (404)
Symptoms: Hosted image URL no longer exists or filename is invalid.
Solutions:
- Check the
/images/{filename}URL - Store important images in your own storage if permanence matters
- Regenerate or re-upload the image
Server Error (500)
Symptoms: Internal server or upstream model error.
Solutions:
- Retry after a short delay
- Try a simpler prompt
- Use a cleaner source image
- Log the payload for debugging
Timeout (504)
Symptoms: Server polling timeout.
Solutions:
- Retry with exponential backoff
- Try
n: 1 - Use a smaller or cleaner source image
- Prefer file upload or URL over very large base64 payloads
Retry Strategy
Retry:
- Network failures
500errors504timeouts
Do not retry without changes:
400invalid request errors- Invalid image URLs
- Unsupported parameter values
Recommended retry timing:
1 second -> 2 seconds -> 4 seconds -> stop and show the errorTroubleshooting
Image Generation Fails
Diagnostic steps:
- Confirm
promptis not empty - Confirm
modelisnano-banana - Confirm
nis between1and4 - Confirm
aspect_ratiois one of1:1,16:9,9:16,3:4,4:3 - Try a shorter and clearer prompt
Image Editing Fails
Diagnostic steps:
- Confirm both
promptandimageare present - If using GET, confirm
imageis a public URL - If using upload, confirm the field name is
image - Confirm the MIME type is supported
- Try a simple edit instruction first
Upscaling Fails
Diagnostic steps:
- Confirm
imageis present - Confirm
upscale_factorisx2orx4 - Try
x2beforex4 - Use a clean image URL or multipart upload
- Retry after a delay if the response is
504
Base64 Response Does Not Render
Diagnostic steps:
- Check whether the returned value includes a
data:image/...;base64,prefix - If it is raw base64, add the correct data URL prefix before using it in an
<img>tag - Confirm the decoded data is valid image bytes
const src = image.b64_json.startsWith("data:")
? image.b64_json
: `data:image/png;base64,${image.b64_json}`;GET URL Does Not Work
Diagnostic steps:
- URL-encode the prompt
- URL-encode the image URL
- Keep query strings short
- Use POST if the prompt or image input is long
FAQ
General Questions
Q: What is Nano Banana API used for?
A: It is an OpenAI-compatible image API for generating images, editing existing images, and upscaling image resolution.
Q: What is the base URL?
A: https://nanobanana.aikit.club
Q: Does it support chat completions?
A: No. This API is focused on image generation, image editing, image upscaling, and model listing.
Q: Is the API OpenAI-compatible?
A: It uses familiar OpenAI-style image endpoints such as /v1/images/generations, /v1/images/edits, and /v1/models.
Models
Q: Which model should I use for image generation?
A: Use nano-banana.
Q: Which model should I use for image editing?
A: Use nano-banana.
Q: Which model should I use for upscaling?
A: Use the /v1/images/upscale endpoint. The worker exposes imagen-4.0-upscale-preview for upscale support.
Q: Can I request multiple images?
A: Yes. Use n from 1 to 4 for generation and edit requests.
Inputs and Outputs
Q: Can I upload a local image file?
A: Yes. Use multipart form-data with the field name image.
Q: Can I use image URLs?
A: Yes. URLs are supported for POST and GET edit/upscale requests.
Q: Can I use base64 images?
A: Yes for POST edit and upscale requests. You can send a data URL base64 string or raw base64 string.
Q: Should I use size or aspect_ratio?
A: Prefer aspect_ratio. The size parameter exists mainly for OpenAI-compatible legacy integrations.
Q: Should I use url or b64_json?
A: Use url for simple display and downloads. Use b64_json when you want to store or process image bytes yourself.
Technical
Q: Can I use this API from a browser?
A: Yes. The API supports CORS and can be called from browser apps.
Q: Can I use GET endpoints in production?
A: You can, but POST is usually better for production because it handles longer prompts and request bodies more cleanly.
Q: What happens if generation takes too long?
A: The API may return a 504 timeout. Retry with backoff, reduce n, or simplify the request.
Q: Where can AI tools read the docs from MCP?
A: Use the remote MCP server at https://nano-banana-api.readme.io/mcp.
Copy-Paste Starter
const API_BASE = "https://nanobanana.aikit.club";
async function generateImage(prompt) {
const response = await fetch(`${API_BASE}/v1/images/generations`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
prompt,
model: "nano-banana",
n: 1,
aspect_ratio: "1:1",
output_format: "png",
response_format: "url"
})
});
const data = await response.json();
if (!response.ok) {
throw new Error(data.error?.message || "Image generation failed");
}
return data.data[0];
}
generateImage("A cozy robot painting a banana in a sunlit studio")
.then((image) => {
console.log("Image URL:", image.url);
console.log("Revised prompt:", image.revised_prompt);
})
.catch(console.error);Updated 23 days ago
