Loading…
Loading…
https://platform-backend-test.topview.ai/api/v1/models/google/nano-banana-2.1/text-to-image/predictionsAuthenticate with your Platform API key in the Authorization header.
Authorization: Bearer YOUR_PLATFORM_KEYManage API keys Your key needs models:generate and requests:read permissions. Only the following parameters are supported. Unsupported fields return 400 without a charge.
Submit model parameters directly; no estimate request is required. Save data.id to retrieve status, results and the final charge.
# Set TOPVIEW_API_PLATFORM_KEY once. Preserve REQUEST_KEY and input for uncertain retries.
# For a NEW task only, unset REQUEST_KEY first. Save data.id to resume GET only.
: "${TOPVIEW_API_PLATFORM_KEY:?Set TOPVIEW_API_PLATFORM_KEY first}"
export REQUEST_KEY="${REQUEST_KEY:-$(uuidgen)}"
curl --fail-with-body 'https://platform-backend-test.topview.ai/api/v1/models/google/nano-banana-2.1/text-to-image/predictions' \
-H "Authorization: Bearer $TOPVIEW_API_PLATFORM_KEY" \
-H "Idempotency-Key: $REQUEST_KEY" \
-H 'Content-Type: application/json' \
--data '{
"prompt": "A blue ceramic cup on a wooden table",
"resolution": "1k",
"aspect_ratio": "1:1"
}'Use a unique Idempotency-Key per task. Retry an uncertain submission with the same key and request. Python / JavaScript save input and idempotency key before submission in REQUEST_STATE (default .topview-request.json); keep this file private. Restart with the same file to recover, or set TASK_ID for GET-only recovery. Use a new state path for a new task. Polling retries network errors, 429 and 5xx with bounded backoff and Retry-After; after the retry limit or 30 minutes, resume the saved task ID.
Submit asynchronously and poll for results.
https://platform-backend-test.topview.ai/api/v1/predictions/REQUEST_IDReplace REQUEST_ID with data.id. Poll data.status until completed or failed; successful results are in data.outputs.
curl --fail-with-body 'https://platform-backend-test.topview.ai/api/v1/predictions/REQUEST_ID' \
-H "Authorization: Bearer $TOPVIEW_API_PLATFORM_KEY"{
"code": 200,
"message": "success",
"data": {
"id": "TASK_ID",
"status": "completed",
"outputs": [
"https://example.com/generated-result"
],
"charged_usd": "0.040000000000",
"billing_state": "CAPTURED",
"error": ""
}
}createdprocessingpayment_requiredcompletedfaileddata.charged_usd is the actual task cost in USD, returned as an exact decimal string. data.billing_state: RESERVED holds funds, CAPTURED settles the charge, and RELEASED returns the hold.
Request and response schemas for the selected mode.
Each request generates one image asynchronously and returns a URL. Display prices are estimates; settlement uses actual consumption and releases unused funds. Read data.charged_usd for the actual USD charge.
If data.execution_state is REVIEW_REQUIRED, the upstream result or charge needs reconciliation and status may remain processing. Keep the task ID and contact support; do not resubmit with a new Idempotency-Key. Funds may remain RESERVED until reconciliation; a hold is not a completed charge.
Common parameters match the Playground form. Use the API field path in request JSON; descriptions explain nested fields and media roles. — means no declared default, not null or zero.
| Parameter / API path | Required | Type | Default | Options / limits | Description |
|---|---|---|---|---|---|
prompt | Yes | string | — | max length 10000 | Describe the desired content. |
aspect_ratio | No | string | "1:1" | "1:1", "3:2", "2:3", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9", "1:4", "4:1", "1:8", "8:1" | Output aspect ratio. |
resolution | No | string | "1k" | "1k", "2k", "4k" | Output resolution. |
| Parameter / API path | Required | Type | Default | Options / limits | Description |
|---|---|---|---|---|---|
output_format | No | string | "png" | "png", "jpeg" | Output file format. |
enable_base64_output | No | boolean | false | true, false | No additional description published. |
enable_sync_mode | No | boolean | false | false | Only asynchronous submission is supported; true is not available. |
{
"type": "object",
"additionalProperties": false,
"required": [
"prompt"
],
"properties": {
"enable_base64_output": {
"type": "boolean",
"default": false
},
"output_format": {
"type": "string",
"enum": [
"png",
"jpeg"
],
"default": "png"
},
"prompt": {
"type": "string",
"maxLength": 10000
},
"aspect_ratio": {
"type": "string",
"default": "1:1",
"enum": [
"1:1",
"3:2",
"2:3",
"3:4",
"4:3",
"4:5",
"5:4",
"9:16",
"16:9",
"21:9",
"1:4",
"4:1",
"1:8",
"8:1"
]
},
"resolution": {
"type": "string",
"enum": [
"1k",
"2k",
"4k"
],
"default": "1k"
},
"enable_sync_mode": {
"type": "boolean",
"enum": [
false
],
"default": false,
"description": "Only asynchronous submission is supported; true is not available."
}
}
}Task query response. Generation results are inside data. Nested field presence depends on the parent being returned.
| Parameter / API path | Required | Type | Default | Options / limits | Description |
|---|---|---|---|---|---|
code | Yes | integer | — | — | HTTP API envelope code. Inspect data.status for the task outcome. |
message | Yes | string | — | — | API response message. |
data | Yes | object | — | — | Prediction task details. |
data.id | Yes | string | — | — | Platform task ID. Persist it before polling. |
data.created_at | Yes | string | — | date-time | Task creation timestamp. |
data.code | Yes | integer | — | — | 0 for normal tasks; 402 when payment is required; 1403 for a failed task. |
data.execution_state | Yes | string | — | — | Execution state; inspect status and billing_state before treating a task as settled. |
data.status | Yes | string | — | "created", "processing", "payment_required", "completed", "failed" | Current task status. |
data.outputs | Yes | string[] | — | — | Empty until settled successfully. HTTPS result URLs or image data; enable_base64_output returns raw Base64 without a data URI prefix. |
data.amount_due_usd | No | string | — | — | Full actual cost in USD, present when status is payment_required. |
data.additional_charge_usd | No | string | — | — | Actual cost minus the original reservation; present when payment is required. |
data.shortfall_usd | No | string | — | — | Additional eligible balance needed at the latest settlement attempt. Top up this workspace; settlement retries automatically. No duplicate submission is needed. |
data.charged_usd | Yes | string | — | — | Actual USD charge as an exact decimal string, not the reserved amount. |
data.billing_state | Yes | string | — | "RESERVED", "CAPTURED", "RELEASED" | RESERVED is a temporary hold, not spending. CAPTURED is the final charge. RELEASED returns the full hold after failure; released funds are not recharge income. |
data.error | Yes | string | — | — | Failure or payment-required description, otherwise an empty string. |
data.urls | Yes | object | — | — | Task-related API URLs. |
data.urls.get | Yes | string | — | uri | Authenticated polling URL. Use the original creating API key with requests:read and the corresponding mode permission. |
data.last_frame_url | No | string | — | uri | Last-frame image URL when requested and returned, available only after settlement. |
{
"type": "object",
"required": [
"code",
"message",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "HTTP API envelope code. Inspect data.status for the task outcome."
},
"message": {
"type": "string"
},
"data": {
"type": "object",
"required": [
"id",
"created_at",
"code",
"execution_state",
"status",
"outputs",
"charged_usd",
"billing_state",
"error",
"urls"
],
"properties": {
"id": {
"type": "string",
"description": "Platform task ID. Persist it before polling."
},
"created_at": {
"type": "string",
"format": "date-time"
},
"code": {
"type": "integer",
"description": "0 for normal tasks; 402 when payment is required; 1403 for a failed task."
},
"execution_state": {
"type": "string",
"description": "Execution state; inspect status and billing_state before treating a task as settled."
},
"status": {
"type": "string",
"enum": [
"created",
"processing",
"payment_required",
"completed",
"failed"
]
},
"outputs": {
"type": "array",
"items": {
"type": "string"
},
"description": "Empty until settled successfully. HTTPS result URLs or image data; enable_base64_output returns raw Base64 without a data URI prefix."
},
"amount_due_usd": {
"type": "string",
"description": "Full actual cost in USD, present when status is payment_required."
},
"additional_charge_usd": {
"type": "string",
"description": "Actual cost minus the original reservation; present when payment is required."
},
"shortfall_usd": {
"type": "string",
"description": "Additional eligible balance needed at the latest settlement attempt. Top up this workspace; settlement retries automatically. No duplicate submission is needed."
},
"charged_usd": {
"type": "string",
"description": "Actual USD charge as an exact decimal string, not the reserved amount.",
"pattern": "^[0-9]+(\\.[0-9]+)?$",
"example": "0.040000000000"
},
"billing_state": {
"type": "string",
"description": "RESERVED is a temporary hold, not spending. CAPTURED is the final charge. RELEASED returns the full hold after failure; released funds are not recharge income.",
"enum": [
"RESERVED",
"CAPTURED",
"RELEASED"
]
},
"error": {
"type": "string",
"description": "Failure or payment-required description, otherwise an empty string."
},
"urls": {
"type": "object",
"required": [
"get"
],
"properties": {
"get": {
"type": "string",
"format": "uri",
"description": "Authenticated polling URL. Use the original creating API key with requests:read and the corresponding mode permission."
}
}
},
"last_frame_url": {
"type": "string",
"format": "uri",
"description": "Last-frame image URL when requested and returned, available only after settlement."
}
}
}
}
}| HTTP | What it means and what to do |
|---|---|
400 | Some parameters are invalid or unsupported. Check the schema and update your request. |
401 | Missing or invalid credentials. Check your API key. |
403 | Your API key doesn’t have the required permissions or model access. Check its settings. |
404 | This resource wasn’t found or isn’t accessible to your workspace. |
409 | Idempotency or version conflict. Check the original request. |
429 | Concurrency or rate limit reached. Wait and retry with backoff. |
5xx | Temporary server error. Wait before retrying status checks. If you’re unsure whether a submission succeeded, retry with the same Idempotency-Key and request body. |
HTTP success does not guarantee generation success. Inspect data.status, data.error and billing_state.