Errors & safe retries
Handle API errors, rate limits, idempotency and processing costs without duplicate submissions.
Error format
Section titled “Error format”Errors use application/problem+json. Branch on the HTTP status and stable code, not the text of detail; requestId matches the X-Request-ID response header for diagnostics. Schema errors may additionally include an errors array describing invalid fields. An illustrative error body:
{"status": 401, "code": "UNAUTHENTICATED", "detail": "Provide a valid API key.", "requestId": "REQUEST_ID"}| Status | What to do |
|---|---|
400 |
Fix malformed JSON or invalid task/media settings |
401 |
Check the key, site, expiry and revocation |
402 |
Check credits or account restrictions in the workspace |
403 |
Use a key with the required scope |
404 |
Check the ID; missing and other users’ resources are not exposed |
409 |
Inspect the quote, idempotency key or task state; do not blindly resubmit |
410 |
Output was deleted, or the original idempotent task was cleaned up |
413 |
Reduce the upload/request size |
422 |
Fix fields against the endpoint schema |
429 |
Wait for Retry-After and reduce concurrency |
500 / 502 / 503 / 504 |
Back off with jitter; preserve a submission’s key and body |
Retry the same logical task
Section titled “Retry the same logical task”Persist the Idempotency-Key and request body before the first POST /tasks. If the connection times out or the server response is lost, send the same key and body again. Within one account, the same request returns the original task even after rotating API keys. Different parameters with the same key return 409. JSON formatting and property order do not matter.
An expired quote may still belong to a submission that succeeded but whose response was lost: retry the original key/body first to recover that task. Refresh a quote and use a new key only after confirming that you are creating a new logical task. After a task is cleaned up, its key remains reserved and replay returns 410.
Never retry all errors automatically. For retriable failures use bounded exponential backoff with jitter; honor Retry-After when present. A client timeout does not cancel a server task. Do not log API keys or signed URLs.
Rate limits and polling
Section titled “Rate limits and polling”Each key allows at most 120 requests in any rolling 60-second period. Twenty invalid key attempts from one IP within a minute trigger a temporary block. Multiple keys do not raise your account’s processing concurrency, upload allowance or balance. GET /api/v1/benefits reports the effective concurrency for credit-funded tasks; Image Pack tasks have a separate limit. When the task limit is full, the API returns 429 with a suggested Retry-After; capacity may still be full after that delay. Polling every 15 seconds is about 4 requests per minute per active task, so many concurrent tasks need a shared rate budget and a longer interval.
Charges and result retention
Section titled “Charges and result retention”A quote does not reserve credits or compute. A valid quoteId locks the rates, minima and rush terms. Creating a task atomically reserves its estimated credits. Actual output determines the final charge, subject to maxCostCredits (default: quoted amount). An estimate above the cap returns 409. Actual usage above the cap fails the task and releases the reservation. Failed or canceled tasks are not charged; canceling a completed successful task does not reverse its charge.
Refreshing signed result links is free. A deleted output cannot be restored by refreshing its URL. Fetching arbitrary remote source URLs and webhook delivery are not supported in this API; upload files first and poll tasks for completion.
v1 compatibility policy
Section titled “v1 compatibility policy”The /api/v1 paths, authentication, required fields, field types and five task states remain stable. New endpoints and optional fields are compatible additions; clients should ignore unknown response fields. New error codes may be added: fall back to the HTTP status for unknown codes. Discover current capabilities and prices through the catalog and quotes. Breaking changes require /api/v2 and must not replace v1.
Response fields can be both required and nullable. For example, report/watermarkFind on ordinary media tasks, output on detection-report results, and price on unavailable tools may be null. OpenAPI declares the corresponding object type or null; clients must handle both. Requests still reject undeclared fields. Responses allow additional fields that clients should ignore, while typed dictionary values retain their declared constraints.
The repository compatibility check protects base addresses, existing fields, constraints, enums, authentication and HTTP shapes. End-to-end tests also validate actual responses against OpenAPI. These checks do not replace real storage, billing and GPU acceptance checks.