nanobanana API
This platform provides an asynchronous image-generation endpoint for the public model ID nanobanana.
This document is intended for client-side integrators and focuses on the public request path, authentication method, request parameters, and task result contract.
Overview:
- Create task:
POST /v1/images/create - Query task:
GET /v1/tasks/{task_id} - Model ID:
nanobanana - Execution mode: asynchronous task
- Typical scenarios: text-to-image, image editing
Current scope:
- Covers task submission and task query for
nanobanana - Does not expose a synchronous image response mode
input.resolutionis not supportedinput.enable_web_searchis not supported
1. API Overview
- HTTP method:
POST - Request path:
/v1/images/create - Content-Type:
application/json - Result delivery:
- Immediate response returns task acceptance information
- Final result is obtained by polling
/v1/tasks/{task_id}or bycallback_url
2. Authentication and Headers
Example headers:
Authorization: Bearer YOUR_REACH_API_KEY
Content-Type: application/jsonHeader details:
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Platform API key in the format Bearer sk-xxxxxx |
Content-Type | Yes | Must be application/json |
3. Create Task
Request body example:
{
"model": "nanobanana",
"callback_url": "https://your-domain.com/callback",
"input": {
"prompt": "A modern editorial illustration",
"image_urls": [],
"aspect_ratio": "16:9",
"output_format": "png"
}
}3.1 Top-Level Parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Must be nanobanana |
callback_url | string | No | HTTPS callback URL for terminal task states. Maximum length 2048. Localhost, local network, and private network targets are rejected |
input | object | Yes | Image generation parameters |
3.2 input Parameters
| Field | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Generation prompt. Keep it within 2000 tokens where possible |
image_urls | array<string> | No | Reference image URLs. Empty or omitted means text-to-image. Non-empty means image editing. Maximum 5 images |
aspect_ratio | string | No | Output aspect ratio. Supported values: 1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
output_format | string | No | Preferred output format. Supported values: png, jpeg |
Unsupported fields:
input.resolutioninput.enable_web_search
Notes:
output_formatis best-effort. If conversion is unavailable, the task may still succeed with the model's original output format- This model works best with fewer reference images
4. Request Examples
4.1 Text-to-Image Request
curl -X POST "https://direct.reachapi.ai/v1/images/create" \
-H "Authorization: Bearer YOUR_REACH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nanobanana",
"input": {
"prompt": "A playful landing page illustration for a fintech startup",
"aspect_ratio": "16:9",
"output_format": "png"
}
}'4.2 Image Editing Request
curl -X POST "https://direct.reachapi.ai/v1/images/create" \
-H "Authorization: Bearer YOUR_REACH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nanobanana",
"input": {
"prompt": "Transform this food photo into a stylized poster",
"image_urls": [
"https://cdn.example.com/reference-1.png"
],
"aspect_ratio": "4:3",
"output_format": "jpeg"
}
}'5. Create Task Response
Example response:
{
"code": 200,
"msg": "",
"status": "queued",
"task_id": "task_xxx",
"data": []
}Response fields:
| Field | Type | Description |
|---|---|---|
code | integer | Platform business status code |
msg | string | Error or status message |
status | string | Initial task state, typically queued |
task_id | string | Unique task identifier used for later query |
data | array | Empty at submission time |
6. Query Task Status
Request example:
curl -X GET "https://direct.reachapi.ai/v1/tasks/task_xxx" \
-H "Authorization: Bearer YOUR_REACH_API_KEY"Task states:
| Status | Description |
|---|---|
queued | Accepted and waiting to run |
generating | Generation is in progress |
success | Task completed successfully |
failed | Task failed |
Successful response example:
{
"code": 200,
"msg": "",
"status": "success",
"task_id": "task_xxx",
"data": [
{
"url": "https://cdn.example.com/generated/image-1.png"
}
]
}Failed response example:
{
"code": 500,
"msg": "Model service request failed",
"status": "failed",
"task_id": "task_xxx",
"data": []
}7. Callback Delivery
If callback_url is provided when the task is created, the gateway sends a POST request to that URL when the task reaches a terminal state. The callback body uses the same JSON structure as the task query response.
Callback constraints:
- Only
httpsURLs are supported - Maximum length:
2048 localhost,.local, and obvious private-network targets are rejected- Single delivery timeout:
10s - Up to 2 retries after failure, for a maximum of 3 delivery attempts
8. Constraints and Notes
promptmust not be emptyimage_urlssupports at most 5 imagesimage_urlsmust be server-accessiblehttpsURLs- Each input image must be no larger than
10MB aspect_ratioandoutput_formatmust use the documented enum values- For image editing quality, keep the number of reference images as low as practical