Errors, retry policy and request IDs

Classify error codes, read retry-safety fields and use optional idempotency only where it is enabled.

Also available as Markdown · all agent guides in one file

Key points

  • Branch on codes, status and the retry-safety fields, not on message text. Keep the request ID for diagnostics.
  • Repeat a POST automatically only when safe_to_retry is true or under an accepted Idempotency-Key.
  • Idempotency-Key works only when the operator configures AETHER_IDEMPOTENCY_DIR. It is not exactly-once execution at the provider.
{
  "error": {
    "message": "Insufficient credits for this request.",
    "type": "insufficient_quota",
    "code": "insufficient_credits",
    "param": null,
    "hint": "Add credits to the wallet used by this key. For shared projects, contact the project owner.",
    "request_id": "req_example",
    "retryable": false,
    "retry_after_ms": null,
    "safe_to_retry": true,
    "execution_status": "not_started",
    "usage_may_have_occurred": false
  }
}

Retry-safety fields

FieldMeaning
retryableThe cause is classified as temporary. It says nothing about whether repeating is safe or free.
retry_after_msThe wait in milliseconds, mirrored from Retry-After (delta seconds or HTTP date), or null when unknown. It does not promise free capacity after the wait.
safe_to_retryRepeating this request cannot cause a second generation by it, because the error happened before any provider attempt or the request was a read (GET, HEAD, OPTIONS). After any provider attempt of a write request it is false, even for 429 or a connection error.
execution_statusnot_started (no provider attempt) or unknown.
usage_may_have_occurredtrue means usage is possible, not that a charge is confirmed.

Inside an SSE stream the HTTP status is already sent; read these fields from the error event.

Decide what to retry

Status or codeAction
400/413/422Fix the request, size or endpoint. wrong_endpoint can supply error.endpoints.
404 model_not_foundRefresh model discovery; do not keep retrying the same ID.
401Fix missing_authorization, invalid_api_key or conflicting_authorization.
403Resolve key/account/project/model access or billing state. Do not work around restrictions by changing identity.
Budget and quota codes daily_limit_reached, monthly_limit_reached, project_member_daily_limit_reached, project_member_monthly_limit_reached, insufficient_credits and devpass_daily_limit_reachedRequire budget, quota reset or user action. Many use 403; do not classify by status alone or assume every limit is a transient 429.
Transient rate_limit_exceeded, provider_rate_limit_exceeded and devpass_rpm_limitWait at least retry_after_ms or Retry-After when supplied. Use bounded exponential backoff with jitter when no delay is supplied.
502 provider_unavailable, 503 temporary service failures and 504 upstream_timeoutMay warrant a bounded retry, but only repeat a POST automatically when safe_to_retry is true or under an accepted Idempotency-Key.
sandbox_disabled and configuration/access errorsNeed corrective action, not repeated generation calls.

Repetition and partial output

Optional idempotency for generation

Operator prerequisite

The Idempotency-Key header is honoured only when the operator configures AETHER_IDEMPOTENCY_DIR on the API server; production enablement is not asserted here.

Idempotency key and fingerprint

Idempotency responses

ResponseMeaningClient action
First accepted call: X-Aether-Idempotency: created——
X-Aether-Idempotency: replayed and X-Aether-Original-Request-IDA finished JSON result is replayed with the same status and body, without a new provider call or charge. An error after a provider may have run, such as a timeout, is stored and replayed too; its Retry-After never starts a new attempt under that key.—
An error that cannot have run or cost anythingIt is not stored and leaves the key free: a rejected request, or every provider refusing it (a 4xx status other than 408, or 501, 503 or 529) or failing before the connection opened.Repeat it with the same key.
409 idempotency_conflictA different request under the same key.—
409 idempotency_in_progress with Retry-After: 2Still running, or unknown after a crash. An entry stays in progress for at most 30 minutes, then fails closed to idempotency_result_unavailable; the key is not released for a new operation before its 24 hours end.Poll only with the same key and an identical request; a new key can start a second billed operation.
409 idempotency_result_unavailableThe result cannot be replayed, for example over 1 MiB, not JSON, a dropped connection, a server restart while it ran or no result after 30 minutes; it is not executed again.—
503 idempotency_store_unavailable with Retry-After: 1No new dispatch, but an earlier operation under this key cannot be ruled out. It also covers a store that is shutting down or an account over its store limit of 10,000 entries or 256 MiB.Do not fall back to a request without the key.
400 idempotency_not_supportedNo store is configured, or the request is not supported.—

No exactly-once guarantee

The guarantee is at most one provider call per accepted key, identity and retention window that can have run and cost anything, including internal fallbacks. It is not exactly-once execution at the provider, not a free retry and not a transaction between provider, billing and the store.

A fallback provider is still tried after an unbilled refusal; after a timeout, a timeout or server error status such as 408, 500, 502 or 504, a lost connection or a success no other provider is tried.

A video replay restores only the job-creation response.

Look up your own request

GET /v1/requests/<request_id> with the same regular API key returns stored HTTP metadata for up to 100 completed requests of that key with this public request ID: timestamp, endpoint, method, model, status, result (success, error or cancelled), error_code, streaming, duration_ms and known token and credit values, plus truncated and coverage.