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#

CallA repeated key returnsKey scope
POST /v1/jobsThe first job, launching nothingYour account
POST /v1/routes/{id}/runsThe first run, launching nothingThe route
POST /v1/routes/{id}/benchmarkThe route's benchmark, launching nothingThe route
POST /v1/webhooksThe first endpoint, with its secretYour account
POST /v1/webhooks/{id}/testThe same test delivery, sending nothing newThe 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.json

Choose 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: 202 for jobs, runs and benchmarks, 201 for a webhook endpoint, 202 for 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_REQUIRED or RUN_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 failed or lost. 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-14
run_job(sample=true, budget_usd=1, idempotency_key="nightly-2026-10-14")

Next steps#