LatentKit

Error Handling

Structured JSON errors, streaming error events, and support correlation IDs.

Request correlation

Every response should include X-LK-Request-ID. Log it with failures when opening support tickets or tracing logs.

Typed JSON errors

Gateway failures return JSON with stable machine-readable codes:

{
  "error": "budget_exceeded",
  "message": "Insufficient credits for Platform Access. Please top up your balance.",
  "code": "budget_exceeded"
}
FieldDescription
errorStable programmatic code
messageHuman-readable detail
codeLegacy alias of error on some responses

Use error as the primary code in new integrations.

Common codes

HTTPCodeMeaning
401missing_api_key / invalid_api_keyFix Authorization header
400validation_errorFix request body
400guardrail_blockedPolicy guardrail rejected input
402 / budget familybudget_exceededCredits or plan limit
503all_providers_exhaustedNo eligible route for capability/profile

Streaming errors

After SSE starts, terminal failures use:

event: error
data: {"error":"budget_exceeded","message":"...","code":"budget_exceeded"}

Client guidance

  1. Read error programmatically; show message to users when appropriate
  2. Retry idempotent requests on transient 5xx with backoff
  3. Do not retry 401, 400, or budget errors without changing inputs or billing state

Upgrade-oriented errors

Some plan-limit responses include fields like upgrade_required and upgrade_to for console-native upgrade flows.

On this page