Skip to content

Error Codes

All errors follow a consistent shape:

json
{ "error": "ERROR_CODE", "message": "Human readable description" }

Error Reference

HTTPCodeWhen
400VALIDATION_ERRORMissing/invalid params, unknown model, amount too low, thinking/reasoning_effort not allowed
401UNAUTHORIZEDMissing/invalid API key or SIWE signature
402INSUFFICIENT_BALANCENot enough credit for the estimated cost
404NOT_FOUNDResource not found
429RATE_LIMITEDPer-wallet rate limit exceeded
500INTERNAL_ERRORServer error
502UPSTREAM_ERRORLLM provider failed or timed out

Detailed Examples

Insufficient Balance (402)

Returned when balance can't cover the pessimistic cost estimate. Includes current balance and required amount.

json
{
  "error": "INSUFFICIENT_BALANCE",
  "message": "Insufficient balance. Top up at /v1/topup.",
  "balance_usdc": 1000,
  "required_usdc": 5000
}

Rate Limited (429)

Returned when per-wallet sliding window limits are exceeded.

json
{
  "error": "RATE_LIMITED",
  "message": "Rate limit exceeded",
  "retry_after_ms": 15000
}

Validation Error (400)

json
{
  "error": "VALIDATION_ERROR",
  "message": "Thinking/reasoning models are not supported"
}

Upstream Error (502)

Returned when the LLM provider fails. Balance lock is released (no charge).

json
{
  "error": "UPSTREAM_ERROR",
  "message": "Provider returned an error"
}

Error Handling Behavior

ScenarioBehavior
Insufficient balanceHTTP 402 with top-up instructions and current balance
Provider downRelease lock, return 502, no balance deducted
Invalid modelReturn 400, release lock, no balance deducted
Rate limitedReturn 429 with retry_after_ms, no balance deducted
Invalid API keyReturn 401
Expired/invalid SIWEReturn 401
Top-up below minimumReturn 400 before issuing 402

Released under the MIT License.