Generate image
POST /api/ai/image/generate — submit a text-to-image or image-to-image task across the Nano Banana model family.
Submits a new image generation task. Credits are pre-debited on submission and refunded automatically if the upstream provider fails the task.
Supported models
| Model ID | Modes | Max refs | Prompt cap | Credit rule |
|---|---|---|---|---|
google/nano-banana | text-to-image, image-to-image | 10 | 5,000 chars | Flat 3 credits per call |
nano-banana-2 | text-to-image, image-to-image | 14 | 20,000 chars | 4 / 6 / 8 credits by 1K / 2K / 4K |
nano-banana-pro | text-to-image, image-to-image | 8 | 10,000 chars | 12 / 20 credits by 2K / 4K |
gpt-image-2 | text-to-image, image-to-image | 4 | 20,000 chars | See the returned creditsUsed value |
Default Nano Banana profile
When model is google/nano-banana, this endpoint behaves as a single unified text/edit API:
inputImageUrlsomitted: text-to-image mode.inputImageUrlspresent: image-to-image edit mode, up to10reference images.aspectRatiosupportsauto,1:1,16:9,9:16,4:3, and3:4.- Current public pricing is a flat
3credits per request.
Field notes
promptis required for every model.inputImageUrlsis the only field that switches the endpoint from generation to editing.aspectRatiois the safest cross-model layout control. Resolution, output format, and similar knobs are model-specific.providerInputis an advanced passthrough for provider-specific overrides. It is not schema-validated, so only use it if you control the upstream contract.- The submitted task response includes
creditsUsed. Use that value instead of reimplementing billing logic client-side.
Authorization
bearerAuth API keys are in closed beta — send your key as Authorization: Bearer <key>. In the meantime, first-party usage from the web dashboard is authenticated via session cookie. See Authentication for details.
In: header
Header Parameters
Required for provider=ai-relay. Persist before the first request; reuse the same key and body for retries. New keys are only for new business jobs.
8 <= length <= 200Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://nanobanana-api.com/api/ai/image/generate" \ -H "Content-Type: application/json" \ -d '{ "prompt": "A luxury skincare bottle on warm paper, embossed serif label, soft editorial side light", "model": "google/nano-banana", "aspectRatio": "4:5" }'{
"taskId": "tsk_01J9XA5M2R9W4QZC4PYJF3N7ND",
"status": 0,
"creditsUsed": 12,
"relayStatus": "string",
"providerTaskId": "string",
"requestId": "string",
"httpRequestId": "string",
"upstreamHttpStatus": 0,
"pollAfterSeconds": 5,
"submissionUncertain": true,
"effectiveWatermark": true,
"demo": true,
"expiresAt": "2019-08-24T14:15:22Z",
"creditRefunded": true
}{
"taskId": "tsk_01J9XA5M2R9W4QZC4PYJF3N7ND",
"status": 0,
"creditsUsed": 12,
"relayStatus": "string",
"providerTaskId": "string",
"requestId": "string",
"httpRequestId": "string",
"upstreamHttpStatus": 0,
"pollAfterSeconds": 5,
"submissionUncertain": true,
"effectiveWatermark": true,
"demo": true,
"expiresAt": "2019-08-24T14:15:22Z",
"creditRefunded": true
}{
"error": "Invalid request",
"details": {}
}{
"error": "Unauthorized"
}{
"error": "Insufficient credits",
"required": 12
}{
"error": "string"
}{
"taskId": "tsk_01J9XA5M2R9W4QZC4PYJF3N7ND",
"status": 0,
"creditsUsed": 12,
"relayStatus": "string",
"providerTaskId": "string",
"requestId": "string",
"httpRequestId": "string",
"upstreamHttpStatus": 0,
"pollAfterSeconds": 5,
"submissionUncertain": true,
"effectiveWatermark": true,
"demo": true,
"expiresAt": "2019-08-24T14:15:22Z",
"creditRefunded": true
}{
"error": "string"
}