Reference
Idempotency
Every call that starts compute or creates a webhook needs an Idempotency-Key, so a retry never launches twice.
Networks fail after the server has acted. If a POST /v1/jobs times out, you cannot tell whether the job started. Sending the same request again with the same key returns the job that was created, instead of starting a second one and paying twice.
Which calls need a key#
| Call | A repeated key returns | Key scope |
|---|---|---|
POST /v1/jobs | The first job, launching nothing | Your account |
POST /v1/routes/{id}/runs | The first run, launching nothing | The route |
POST /v1/routes/{id}/benchmark | The route's benchmark, launching nothing | The route |
POST /v1/webhooks | The first endpoint, with its secret | Your account |
POST /v1/webhooks/{id}/test | The same test delivery, sending nothing new | The endpoint |
Without the header, or with an empty one, these calls answer 400 IDEMPOTENCY_KEY_REQUIRED and store nothing.
curl -s -X POST https://gpu-router.com/v1/jobs \
-H "Authorization: Bearer $GPU_ROUTER_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 7f3c1e0a-train-2026-10-14" \
-d @job.jsonChoose a key#
- Use a new random value, such as a UUID, for each new piece of work.
- Reuse it, unchanged, for every retry of that piece of work.
- Keys do not expire. A key used once always maps to the same resource.
Replay semantics#
- The body is not compared. A replay returns the first resource even if the new body differs. To run a changed job, use a new key.
- Status codes match the first call:
202for jobs, runs and benchmarks,201for a webhook endpoint,202for a test event. - Concurrent duplicates are safe. Two requests racing with the same key create one resource; both get it back.
- Refusals store nothing. When the first call fails with an error such as
JOB_OVER_BUDGET,PROVIDER_CONNECTION_REQUIREDorRUN_LIMIT_REACHED, no resource exists and the key is free to use again, for example after raising the budget. - Accepted launches are kept. Once a run is accepted, its key maps to it even if the launch then fails: a replay returns the run in status
failedorlost. Use a new key to try again.
CLI and MCP#
The CLI (--idempotency-key) and the MCP tools (idempotency_key) generate a new random key when you omit it. That is safe for a single call but not for a retry: pass the same key yourself when you retry.
gpu-router run --sample --budget 1 --idempotency-key nightly-2026-10-14run_job(sample=true, budget_usd=1, idempotency_key="nightly-2026-10-14")