Google - Nano Banana 2 Lite
This page is generated from the upstream official OpenAPI documentation. Endpoints, parameters and examples match the official docs; brand and API domain are replaced with ModelFold.
Endpoint
POST /jobs/createTask
Full URL: https://ai.modelfold.online/v1/jobs/createTask
Authentication: every request must include the
Authorization: Bearer <API_KEY>header.
Create Task
Use this endpoint to create a new image generation task. Provide a text prompt, and optionally include image URLs as visual references.
Output: one JPEG image per task. The output format cannot be set; do not rely on the file extension in the result URL.
Set
image_urlsto an empty array or omit it for pure text-to-image generation. Up to 10 images are supported.Supported aspect ratios:
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,auto.Get Task Details — After submission, use the unified query endpoint to check task progress and retrieve results
TIP
For production use, we recommend providing the callBackUrl parameter so your service can receive completion notifications instead of polling for task status.
Related Resources
- Model Marketplace — Explore all available models and capabilities
- Common API — Check account credits and usage
Request Parameters
Body (application/json)
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model name used for generation. This field is required. This endpoint must use the nano-banana-2-lite model. Default:"nano-banana-2-lite"。 Allowed values:nano-banana-2-lite。 示例:nano-banana-2-lite。 |
callBackUrl | string | No | Callback URL for task completion notifications. Optional parameter. If provided, the system will send a POST request to this URL when the task completes, whether it succeeds or fails. If omitted, no callback notification will be sent. To ensure callback security, see Webhook Verification Guide. 示例:https://your-domain.com/api/callback。 |
input | object | Yes | Input parameters for the image generation task. |
input.image_urls | array<string> | No | Input image URL array. Optional parameter. Set to an empty array or omit it for pure text-to-image generation. Supports up to 10 images. - Please provide uploaded file URLs, not raw file content - Accepted types: image/jpeg, image/png, image/webp- Max size: 30.0MB Default: []。 |
input.prompt | string | Yes | Text prompt used to generate the image. Required. Maximum length: 20000 characters. 示例:Generate a pig on the grass, cinematic light。 |
input.aspect_ratio | string | Yes | Required. Aspect ratio of the output image. Use "auto" to let the model decide. Allowed values: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 / auto。 示例:auto。 |
Request Example
curl -X POST "https://ai.modelfold.online/v1/jobs/createTask" \
-H "Authorization: Bearer $MODELFOLD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana-2-lite",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"image_urls": [
"https://file.aiquickdraw.com/custom-page/akr/section-images/1756223420389w8xa2jfe.png"
],
"prompt": "Generate a pig on the grass, cinematic light",
"aspect_ratio": "auto"
}
}'{
"model": "nano-banana-2-lite",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"image_urls": [
"https://file.aiquickdraw.com/custom-page/akr/section-images/1756223420389w8xa2jfe.png"
],
"prompt": "Generate a pig on the grass, cinematic light",
"aspect_ratio": "auto"
}
}Response
200 — Request successful
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_nanobanana_1765180586443"
}
}Callback
onImageGenerated
Callback URL: {$request.body#/callBackUrl} (the callBackUrl in the request body).
Sent when the task succeeds or fails.
Callback body parameters
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 否 | 200: success. 501: failure; see data.failCode and data.failMsg. Allowed values:200 / 501。 示例:200。 |
msg | string | 否 | Status message 示例:Playground task completed successfully.。 |
data | object | 否 | — |
data.completeTime | integer | 否 | Task completion time, represented as a Unix timestamp in milliseconds 示例:1786429387000。 |
data.costTime | integer | 否 | Processing time in seconds. Present on both success and failure callbacks. 示例:135。 |
data.createTime | integer | 否 | Task creation time, represented as a Unix timestamp in milliseconds 示例:1786429251000。 |
data.creditsConsumed | number | 否 | Credits consumed by the task; 0 for failed tasks. 示例:3。 |
data.model | string | 否 | Image generation model used for the task 示例:nano-banana-2-lite。 |
data.param | string | 否 | Parameters submitted when creating the task, in JSON string format 示例:{"input":"{\"aspect_ratio\":\"auto\",\"image_urls\":[\"https://file.aiquickdraw.com/custom-page/akr/section-images/1756223420389w8xa2jfe.png\"],\"prompt\":\"Generate a pig on the grass, cinematic light\"}","callBackUrl":"https://your-domain.com/api/callback","model":"nano-banana-2-lite"}。 |
data.resultJson | string | 否 | Image generation result in JSON string format. resultUrls contains the list of generated image URLs. Present only when state is success. 示例:{"resultUrls":["https://tempfile.aiquickdraw.com/ggc/226095d9935c83a8a0b4f0e50c235219_1786429384006.jpeg"]}。 |
data.state | string | 否 | Task status Allowed values:success / fail。 示例:success。 |
data.taskId | string | 否 | Task ID 示例:226095d9935c83a8a0b4f0e50c235219。 |
data.updateTime | integer | 否 | Use completeTime as the completion time; updateTime may equal createTime. 示例:1786429387000。 |
data.failCode | string | 否 | Failure code, a numeric string such as "400" or "500". Present only when state is fail. 示例:500。 |
data.failMsg | string | 否 | Failure reason. Present only when state is fail. 示例:<error detail>。 |
Success
{
"code": 200,
"msg": "Playground task completed successfully.",
"data": {
"taskId": "226095d9935c83a8a0b4f0e50c235219",
"model": "nano-banana-2-lite",
"state": "success",
"param": "{\"input\":\"{\\\"aspect_ratio\\\":\\\"auto\\\",\\\"image_urls\\\":[\\\"https://file.aiquickdraw.com/custom-page/akr/section-images/1756223420389w8xa2jfe.png\\\"],\\\"prompt\\\":\\\"Generate a pig on the grass, cinematic light\\\"}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"nano-banana-2-lite\"}",
"resultJson": "{\"resultUrls\":[\"https://tempfile.aiquickdraw.com/ggc/226095d9935c83a8a0b4f0e50c235219_1786429384006.jpeg\"]}",
"completeTime": 1786429387000,
"createTime": 1786429251000,
"costTime": 135,
"creditsConsumed": 3,
"updateTime": 1786429387000
}
}Failure
{
"code": 501,
"msg": "Playground task failed.",
"data": {
"taskId": "226095d9935c83a8a0b4f0e50c235219",
"model": "nano-banana-2-lite",
"state": "fail",
"param": "{\"input\":\"{\\\"aspect_ratio\\\":\\\"auto\\\",\\\"image_urls\\\":[\\\"https://file.aiquickdraw.com/custom-page/akr/section-images/1756223420389w8xa2jfe.png\\\"],\\\"prompt\\\":\\\"Generate a pig on the grass, cinematic light\\\"}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"nano-banana-2-lite\"}",
"failCode": "500",
"failMsg": "<error detail>",
"completeTime": 1786429387000,
"createTime": 1786429251000,
"costTime": 135,
"creditsConsumed": 0,
"updateTime": 1786429387000
}
}