Skip to Content
NineTwo's

Idempotency and recovery

Same-key semantics, 409 distinctions, X-Request-Id, and no-ID recovery.

Idempotency keys

Idempotency-Key is required on every POST /v1/chat/completions request, including streaming requests.

  • Use 1–200 printable, non-whitespace characters with no control characters.
  • Scope uniqueness is organisation + project + key.
  • Use one key per logical operation. Reuse it only for retries of the identical canonical payload.
  • A different canonical payload with the same key returns 409 idempotency_conflict and never dispatches.

Blank, whitespace-only, control-character, or over-length keys are rejected with 400 idempotency_key_required.

Canonical payload

Idempotency is hashed after validation and normalization:

  • max_completion_tokens is canonical; max_tokens is a compatibility alias. The same value under either spelling is the same canonical payload.
  • max_completion_tokens wins when both are present; conflicting values are not rejected.
  • Unknown top-level fields are accepted and ignored, so they are not part of the canonical payload.
  • stream_options accepts only include_usage; unknown properties are rejected with invalid_stream_options.
  • reasoning_effort is part of the canonical payload.

409 responses are not all the same

CodeMeaningClient action
idempotency_conflictSame key was reused with a different canonical payload, or by a different credential in the same project. No replay, dispatch, or charge occurred.Reuse the original credential and payload, or use a new key for a genuinely new logical request.
execution_in_progressThe same-key request is still executing.Retry the same key after a delay, or poll X-Request-Id when supplied.
execution_already_processingAnother worker owns dispatch.Retry the same key after a delay.
terminal_outcomeThe execution reached a released/rejected terminal state.Use a new key for a new logical request.

execution_in_progress, execution_already_processing, and terminal_outcome are distinct from idempotency_conflict. Never respond to an in-progress 409 by changing the payload or minting a new key.

Durable replay and outage behavior

Replay identity is resolved before endpoint resolution, health checks, tokenization, rate limiting, or new charging:

  1. Strict JSON/envelope and parameter-type validation.
  2. Authentication/authorization without requiring current lifecycle availability and without recording usage.
  3. Durable replay lookup by organisation + project + idempotency key.
  4. Credential binding, then canonical payload verification.
  5. Only for new or resumable work: lifecycle availability, admission telemetry, dynamic limits, endpoint/health/tokenization, rate limit, reservation, and dispatch.

New financial requests persist a SHA-256 canonical_payload_digest. Historical immutable rows are not backfilled; for historical settled rows the input digest is reconstructed from immutable metering evidence and admitted_max_output_tokens. If required evidence is missing, the request falls back to the live path rather than guessing.

Consequences:

  • A completed replay returns the stored result even during a model/serving outage, with the same X-Request-Id and no new financial or metering rows.
  • A replay of a request originally made with stream=true returns the stored JSON chat.completion, not an SSE stream. SSE replay is not invented.
  • Dynamic capability limits are enforced only for new or resumable work. Replay uses structural validation, so a previously accepted request remains replayable even if current limits differ.

Cross-credential conflict

The idempotency key is scoped to organisation + project, but it is bound to the credential that created it. A second credential in the same project that reuses the key—even with an identical payload—receives 409 idempotency_conflict before any serving dependency. There is no cross-credential replay, dispatch, or charge.

Recovery headers

X-Request-Id is the gateway execution UUID. It is returned on:

  • successful non-streaming responses and replays;
  • streaming response headers;
  • 409 execution_in_progress and 409 execution_already_processing;
  • post-reservation 429 concurrency_limit;
  • 503 inference_unavailable and 503 inference_outcome_unknown when an execution exists;
  • other post-admission errors associated with an execution.

Use it with GET /v1/requests/{id}. The id must be a canonical UUID; malformed ids return 400 invalid_id.

Recovery when no request id was received

There is deliberately no public idempotency-key lookup endpoint. Preserving the key and payload is the recovery mechanism:

  1. Retry the same Idempotency-Key with the identical canonical payload.
  2. If the original settled, the stored completion is replayed with 200 and the same X-Request-Id.
  3. If it is still executing, the response is 409 execution_in_progress with X-Request-Id; poll GET /v1/requests/{id}.
  4. If it was reserved but never dispatched (for example after a concurrency 429), the retry resumes that reservation.
  5. If it reached a released/rejected terminal state, the response is terminal_outcome; only then use a new key for a new logical request.
# Same key and same payload: recover an uncertain outcome.
curl -sS "$NINETWOS_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $NINETWOS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: chat-001" \
  -d '{
    "model": "zuv-0.5",
    "messages": [{"role": "user", "content": "Summarize this ticket"}],
    "max_completion_tokens": 256
  }'

Terminal outcomes

503 inference_unavailable is a definite pre-dispatch refusal whose reservation was released. Retrying the same key returns terminal_outcome; only then use a new key for a new logical request.

503 inference_outcome_unknown means the request may have reached the GPU. Never start a new logical request. Retry the same key to recover X-Request-Id, then poll request status.

A timeout or dropped connection does not prove failure. Never blind-restart with a new key, and never change the payload to "make the retry work".

On this page