Nano Banana 2
Generate and transform images with Nano Banana 2 through async media tasks.
Nano Banana 2 supports text-to-image and image-to-image tasks with up to 14 reference images, with fast and pro modes.
Model information
| Item | Value |
|---|---|
| Model ID | nano-banana-2 |
| Endpoint | POST /v1/router/task/create |
| Task types | Txt2Img, Img2Img |
| Operation | Create an asynchronous task, then poll for its result |
Async task workflow
- Prepare input media. Image-to-image inputs must be publicly reachable direct HTTPS URLs. Pass up to 14 jpeg/png/webp images, each no more than 30 MB. Local files, Base64 / Data URLs, and existing remote URLs can be converted to a public
fileUrlwith HopsAPI file uploads. Do not passasset://,s3://,file://, or private-network URLs directly. - Create the task. Send the model-specific
task,model,mode, andinputfields documented below toPOST /v1/router/task/create. The response guarantees a platformtask_idintsk_*format; other success fields come from the current upstream and are not a fixed contract. Optionalcallback_urlreceives a signed webhook when the task finishes. See Media task callbacks. That URL is not forwarded upstream. - Poll or cancel. Save
task_idand callGET /v1/router/tasks/{task_id}every 3–5 seconds. To stop a queued or processing task, send{"task_id":"tsk_..."}toPOST /v1/router/task/stop. An API key can only query or cancel tasks owned by the same buyer. - Read the result. Continue polling until the task reaches a terminal status:
| Status | Meaning |
|---|---|
0 | Queued — submitted and awaiting scheduling |
1 | Processing — the model is generating |
2 | Completed — output URLs are usually in results[].urls; cost is your price in credits |
3 | Failed — the reserved amount is released and no charge is settled |
4 | Cancelled — the reserved amount is released and no charge is settled |
Failure responses are intentionally neutral and do not expose upstream details. Use the request id in Provider error (request id: aitk-...) to correlate server logs; do not depend on error_message, fail_reason, or message for provider diagnostics. The fixed price shown below is locked at task creation and temporarily reserved from the available balance before upstream submission. It is settled only after successful completion. Failure or cancellation releases the reserved amount without a charge, and the upstream provider's actual cost does not determine the buyer price.
Result URLs expire in about 24 hours. Download and store the output promptly.
Use model="nano-banana-2" for Txt2Img and Img2Img. Top-level mode accepts fast or pro, defaults to pro, and is passed upstream unchanged.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
task | string | Yes | Txt2Img for generation or Img2Img for transformation |
model | string | Yes | Set to nano-banana-2 |
mode | string | No | fast or pro; defaults to pro |
input.prompt | string | Yes | Image generation or editing prompt |
input.images | string[] | Image-to-image | 1–14 public HTTPS image URLs |
input.aspect_ratio | string | Yes | Choose from the list below; auto is not supported |
input.resolution | string | Yes | fast: 2K / 4K; pro: 1K / 2K / 4K |
input.output_format | string | No | jpg or png |
callback_url | string | No | Optional public HTTPS webhook. See Media task callbacks. |
Supported aspect_ratio 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
Fast mode accepts 2K or 4K; pro accepts 1K, 2K, or 4K. output_format accepts jpg or png. Image-to-image images accepts up to 14 public HTTPS URLs.
Fixed prices
Official prices are in credits per task; your charge is the table price × your configured coefficient.
| Mode | Task | 1K | 2K | 4K |
|---|---|---|---|---|
fast | Txt2Img / Img2Img | Not supported | 5 | 8 |
pro | Txt2Img | 7 | 10 | 15 |
pro | Img2Img | 7 | 11 | 16 |
Request examples
# Text-to-image
curl https://hopsapi.com/v1/router/task/create \
-H "Authorization: Bearer sk-YOUR_KEY" -H "content-type: application/json" \
-d '{"task":"Txt2Img","model":"nano-banana-2","mode":"fast",
"input":{"prompt":"a red apple on a white background","aspect_ratio":"1:1","resolution":"2K","output_format":"jpg"}}'# Image-to-image (transform / reference)
curl https://hopsapi.com/v1/router/task/create \
-H "Authorization: Bearer sk-YOUR_KEY" -H "content-type: application/json" \
-d '{"task":"Img2Img","model":"nano-banana-2","mode":"fast",
"input":{"prompt":"change the material to transparent glass","images":["https://input.png"],"aspect_ratio":"1:1","resolution":"2K","output_format":"png"}}'Create response
Current upstream success response example:
{
"code": 200,
"message": "task created",
"task_id": "tsk_01H..."
}The gateway preserves other upstream success fields but only guarantees rewriting task_id to the platform tsk_* ID. Store task_id and poll it as described above. Successful output URLs are usually in results[].urls.