Overview
Use your API key to generate images via a simple HTTP endpoint. Credits are automatically deducted based on the number of images generated.
Endpoint
- Method:
POST - URL:
https://api.nanobananaapi.dev/v1/images/generate
Authentication
Include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Content-Type: application/jsonRequest Body (Client)
{
"prompt": "A serene mountain landscape at sunset with a lake reflecting the orange sky",
"num": 1,
"model": "gemini-3-pro-image-preview",
"image_size": "16:9"
}Credit Deduction
- gemini-2.5-flash-image: Per image:
2credits - gemini-3-pro-image-preview: Per image:
10credits - If credits are insufficient, the API returns an error.
Response
All responses use a unified JSON format:
{
"code": 0,
"message": "ok",
"data": {
"url": "https://api.nanobananaapi.dev/v1/images/1234567890.png"
}
}Error responses:
{
"code": -1,
"message": "insufficient credits"
}Common error messages:
invalid api keyinvalid request typeinsufficient creditsgenerate failed
Examples
curl
curl -X POST "https://api.nanobananaapi.dev/v1/images/generate" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A serene mountain landscape at sunset with a lake reflecting the orange sky",
"num": 1,
"model": "gemini-3-pro-image-preview",
"image_size": "16:9"
}'Node.js
async function generate() {
const res = await fetch('https://api.nanobananaapi.dev/v1/images/generate', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt:
'A serene mountain landscape at sunset with a lake reflecting the orange sky',
num: 1,
model: 'gemini-3-pro-image-preview',
image_size: '16:9',
}),
});
const result = await res.json();
if (result.code !== 0) throw new Error(result.message);
return result.data;
}