Why
A media generation is charged when it succeeds. If your connection drops after RouterBase accepts the request but before the response delivers the generationid, you are left with a task you cannot poll — and a blind retry
would create (and charge) a second generation.
Supplying an idempotency id closes both gaps:
- Retries are safe. A request with an id you already used replays the
existing generation — same
id, currentstatus, anddatawhen it has finished — instead of creating a new one. No double charge. - Lost tasks are recoverable.
GET /v1/videos/generations?client_request_id=...returns the generation created under that id, even if you never saw the original response.
POST /v1/images/generations, POST /v1/videos/generations,
POST /v1/audio/speech, and POST /v1/audio/generations. Requests without
an id behave exactly as before.
Supplying an id
Send either anIdempotency-Key header (the header wins if both are present)
or a client_request_id field in the JSON body. Use a fresh unique value per
logical request — a UUID is ideal. Ids are 1–128 visible ASCII characters and
are scoped to your account.
Recovering after a dropped connection
If the POST times out or the connection resets, do not immediately assume the task was lost — look it up:200— the request did go through. The response is the standard generation object (id,status,data[].urlwhen finished); continue pollingGET /v1/videos/generations/{id}as usual.404— the request never reached RouterBase. Retry the POST with the same id; if the 404 raced a request still being accepted, the retry simply replays it.
/v1/images/generations and
/v1/audio/generations.
Retry semantics
- A replayed request returns the stored generation in whatever state it is
in (
pending,success, orfailed) — it does not re-run the task, and the request body of the retry is ignored. - A
failedgeneration is not retried under the same id (you were not charged for it). Use a fresh id to try again. - Two concurrent requests with the same id are safe: exactly one generation is created, and the other request replays it.