google/nano-banana-2
Image · Typically $0.072053 per image
Endpoint
POST /v1/images/generations — answers 202 with a job. Poll GET /v1/jobs/{id}, or receive it by webhook, until its state is final.
Dependencies
- height needs width sent with it.
- resolution needs reference_images sent with it.
- resolution cannot be sent with height or width.
- width needs height sent with it.
Request
curl https://api.opinference.com/v1/images/generations \
-H "Authorization: Bearer $OP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/nano-banana-2",
"prompt": "a paper boat drifting down a rain gutter"
}'Response
The job resource once it has succeeded.
{
"id": "job_01J9K2…",
"generation_id": "gen_01J9K2…",
"object": "job",
"state": "succeeded",
"modality": "image",
"model": "google/nano-banana-2",
"created_at": "2026-09-30T08:00:00Z",
"started_at": "2026-09-30T08:00:04Z",
"completed_at": "2026-09-30T08:01:12Z",
"output": [
{
"url": "https://…?X-Amz-Signature=…",
"url_expires_at": "2026-09-30T09:01:12Z",
"type": "image/png",
"bytes": 1482113,
"checksum_sha256": "…"
}
],
"usage": {
"units": {
"image": 1
}
}
}Input
A JSON body. A key not listed here is refused, and the error names it.
| Field | Description |
|---|---|
| modelstring · required | The id of this model. |
| promptstring · required | What the image should show.Up to 45000 characters |
| heightinteger | Output height in pixels. |
| ninteger | How many images to generate.From 1 to 20 · Default: 1 |
| output_formatenum | File format of the generated image.One of: JPG, PNG, WEBP · Default: JPG |
| reference_imagesURL[] (image) | Images that guide style, subject or composition.Up to 14 items |
| resolutionenum | Output size tier.One of: 0.5K, 1K, 2K, 4K |
| seedinteger | Fixes the random seed, so the same request can reproduce an image.From 0 to 2147483647 |
| widthinteger | Output width in pixels. |
| modelsstring[] | Other model ids to try, in order, if this one is unavailable. Up to 5. |
| providerobject | Routing preferences: region, zdr, data_collection, sort, max_price. |
| opobject | Gateway options: retention (may only tighten), tags, session_id. |
Output
A job resource.
| Field | Description |
|---|---|
| id | The job id. Poll GET /v1/jobs/{id} with it. |
| generation_id | The generation this job belongs to. |
| object | Always "job". |
| state | queued, processing, succeeded, failed or canceled. The last three are final. |
| modality | The kind of output. |
| model | The model id that was asked for. |
| created_at | When the job was accepted. |
| started_at | When work began. Absent while queued. |
| completed_at | When the job reached a final state. |
| progress.percent | Percent complete, 0 to 100, or null when not reported. |
| progress.phase | queued, running or done. |
| progress.queue_position | Always null today. |
| output[] | The files produced: url (signed, re-issued on every read), url_expires_at, type, bytes, checksum_sha256. |
| usage | The billable units the job consumed. |
| usage.cost | An estimate from the published price: billing_usd, cost_source, cost_status ("estimated") and price_version. Your balance is charged the settled amount. |
| op_metadata | What applied when the job was accepted: generation_id, requested_model, retention_class, region and policy[]. |
| error | On failure: code, kind and a fixed message for the code. |