OpenToken Docs

Errors

OpenAI-compatible error envelope, status codes, and types returned by the OpenToken API.

OpenToken returns errors in the OpenAI-compatible envelope. Every failed request carries a JSON body with a single error object.

{
  "error": {
    "message": "model \"openai/gpt-4o\" not found",
    "type": "invalid_request_error",
    "code": "model_not_found"
  }
}
  • message — human-readable description of what went wrong.
  • type — broad category, aligned with the HTTP status.
  • code — specific machine-readable reason. May be null when no finer code applies.

Status codes

HTTPtypecodeWhen
400invalid_request_errormodel_not_foundThe {provider}/{model} id is not registered. See Models.
400invalid_request_errorMalformed body, unknown field, or failed schema validation.
401authentication_errorMissing or invalid Authorization header. Keys start with sk-optk-.
402invalid_request_errorinsufficient_creditThe workspace credit balance is non-positive or no billing account exists.
404invalid_request_errornot_foundThe request path does not match a known route.
429invalid_request_errorspend_limit_exceededA per-key spend limit was reached.
500api_errorUnexpected internal error. Carries an extra event_id field for support correlation.
502upstream_errorvertex_auth_failedUpstream credential exchange failed (Vertex).
503upstream_errorno_supplierNo provider is available to serve the model.
504upstream_errorupstream_timeoutThe upstream provider did not respond in time.

An unregistered id such as openai/gpt-4o returns 400 model_not_found (no openai/* model is in the catalog). The full set of routable model ids is on the Models page.

Errors during streaming

When stream: true, a request can succeed with 200 OK and then fail mid-stream. In that case the error is delivered as a plain data: line carrying the error envelope rather than an HTTP status. The stream still terminates with a data: [DONE] line afterward.

data: {"error":{"message":"stream interrupted","type":"upstream_error","code":"stream_error"}}
data: [DONE]

Parse each data: line for an error key in addition to checking the initial HTTP status. See Streaming.

Handling errors

Branch on error.code when present and fall back to error.type otherwise. Treat 429, 503, and 504 as retryable; treat 400, 401, and 402 as terminal until the request or account state changes.