AI Relay
Discover models, submit an idempotent Relay task, and download protected results.
Authenticate with your application API key or login session. The Relay site key stays on the server.
- Call
GET /api/ai/modelsand select a permitted model/specification withenabled: true. Only the Nano Banana family (nano-banana,nano-banana-2,nano-banana-pro) is exposed; other IDs are rejected on submission. Discovery does not guarantee provider availability. - Persist an
Idempotency-Keyof 8–200 printable characters alongside the original request before submitting. Every retry uses the same key and body. - Submit to
POST /api/ai/image/generateorPOST /api/ai/video/generatewithprovider: "ai-relay", the discoveredmodel,prompt,resolution,numOutputs: 1, andwatermark: false. Video also requires a discovered integerduration. - Keep the returned application
taskId; pollGET /api/ai/tasks/{id}at intervals of at leastpollAfterSeconds. Polling never submits a generation. - For
status: 1, downloadoutputImageUrls/outputVideoUrlthrough the returned application URLs. Downloads require your application API key or same-origin session cookie. Video supports one byte Range.
Reference images, arbitrary parameters, callbacks, client identity fields, multiple outputs and video watermarking are rejected. Requests without provider: "ai-relay" retain the existing provider flow.
SUBMISSION_UNKNOWN means acceptance could not be confirmed. Replay only the original POST with its original key/body. RECONCILING and FINALIZING remain pending even with an error code. Browser cancellation or timeout only ends that wait; resume the same task later.
The application taskId identifies a saved business request; it can exist before Relay has acknowledged an upstream task. If status: 0, submissionUncertain: true and no providerTaskId are returned, recover with the saved POST/key/body. Once providerTaskId exists, only poll the original application task. An expired or terminal task must never trigger another automatic submission.
The Nano Banana, Nano Banana 2 and Nano Banana Pro pages use this same Relay playground. Their model selection comes from authenticated discovery, preserves the selected model across login, and does not silently substitute a different model if the requested one is unavailable. Resuming a saved request remains possible after the initial credit debit, even when the remaining balance cannot fund a new request.
SUCCEEDED, FAILED and CLOSED_UNKNOWN are terminal. A budget rejection returns HTTP 429 with a saved task snapshot; keep its taskId. Confirmed FAILED tasks receive the application's customer-credit refund once. Unknown closures, conflicts and expired/unavailable tasks require manual reconciliation and do not automatically refund credits. This is separate from any Relay/supplier billing.
Media expires after 30 days. HTTP 404/410 never authorizes automatic regeneration. Result URLs are private, not permanent public CDN links.
Operators configure AI_RELAY_BASE_URL / AI_RELAY_SITE_KEY on the server and apply database migrations. pnpm relay:check performs health/model GET requests only, without generation.