idempotency_key_required means a POST /v1/runs request arrived without an Idempotency-Key header. Read this page if you are writing your first run request, or if a client library strips custom headers.
What happened
Route:POST /v1/runs.
Every run must carry an Idempotency-Key header. The key lets OpenType recognise a retry of the same request and return the stored run instead of running and charging it twice. The request had no such header, so it was refused before a run existed. Nothing was stored and nothing was charged.
This check runs after the credential is accepted, the body is parsed and the runs_write scope is confirmed. A request that fails one of those gets that error instead.
How to fix
Send the header on everyPOST /v1/runs:
Choose the key per logical request, not per HTTP attempt:
- Derive it from your own business id, such as
ticket-4822-triage. The same ticket and the same question always produce the same key. - Reuse that key when you retry the same request after a timeout or a dropped connection. If the first attempt produced a finished run, you get it back with
"replayed": trueand pay nothing more. - Use a new key after a 5xx or 504 that ended the run before the model answered. A replay of that key returns the stored
pendingrun with202instead of running again. See Error handling. - Use a new key when you change the body. Reusing a key with a different body gets
idempotency_conflict.
Example
Related
- Idempotency - replays, conflicts, and when to mint a new key.
- invalid_idempotency_key - the header is present but not a valid key.
- Problem codes - every code, its status, and whether a retry can help.
- Errors - the error envelope and the status families.