Nano Banana 2 Text to Image API
Get API Keynano-banana-2-text-to-image
Create Task
POST https://aigptimage.com/api/v1/jobs/createTask
Authorization: Bearer YOUR_API_KEY
Content-Type: application/jsonInput Parameters
| Field | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Text description of the image to generate. Max 20000 characters |
aspect_ratio | string | No | Options: auto, 1:1, 1:4, 1:8, 2:3, 3:2, 3:4, 4:1, 4:3, 4:5, 5:4, 8:1, 9:16, 16:9, 21:9. Default: auto |
resolution | string | No | 1K, 2K, or 4K. Default: 1K |
output_format | string | No | png or jpg. Default: png |
Request Example
{
"model": "nano-banana-2-text-to-image",
"input": {
"prompt": "A clean product photo of a futuristic yellow camera on a white desk",
"aspect_ratio": "auto",
"resolution": "1K",
"output_format": "png"
}
}Create Response
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_xxxxxxxxxxxxx"
}
}Save data.taskId; you need it to query the result.
Query Task
GET https://aigptimage.com/api/v1/jobs/recordInfo?taskId=task_xxxxxxxxxxxxx
Authorization: Bearer YOUR_API_KEYWhen data.state is success, parse data.resultJson as JSON and read resultUrls.
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_xxxxxxxxxxxxx",
"model": "nano-banana-2-text-to-image",
"state": "success",
"param": "{\"model\":\"nano-banana-2-text-to-image\",\"input\":{\"prompt\":\"A clean product photo of a futuristic yellow camera on a white desk\",\"aspect_ratio\":\"auto\",\"resolution\":\"1K\",\"output_format\":\"png\"}}",
"resultJson": "{\"resultUrls\":[\"https://cdn.example.com/result.png\"]}",
"failCode": null,
"failMsg": null,
"costTime": 12000,
"completeTime": 1757584176490,
"createTime": 1757584164490
}
}Error Codes
| Status Code | Description |
|---|---|
400 | Invalid request parameters |
401 | Authentication failed or API key is invalid |
402 | Insufficient credits |
404 | Task not found |
409 | Active task limit exceeded or request conflict |
422 | Parameter validation failed |
429 | Request rate limit exceeded |
500 | Internal server error |