Skip to main content
OpenAI-compatible TokenLab errors can include structured hints for an agent or application. Use these fields when present; do not parse the human-readable message to decide what to do. Anthropic Messages and Gemini APIs keep their native error formats, so the extensions on this page apply only to OpenAI-compatible Chat Completions and Responses errors.

Optional error fields

All fields below appear inside the error object and may be absent. Your client should still handle every error by its HTTP status and code. Treat these extra fields as useful context, not required fields.

Unknown model

A misspelled or unavailable model returns 400 model_not_found. If did_you_mean is present, show it to the user or retry only when your product already has permission to change the selected model.

Insufficient balance

402 insufficient_balance can include the current balance and the estimated amount required. Your application can offer a top-up link, a less expensive model, or a smaller request.

Temporarily unavailable

A 503 all_channels_failed response means the requested model is temporarily unavailable. Respect retry_after when retryable is true, or let the user choose an item from alternatives.

Rate limit

For 429 rate_limit_exceeded, wait for retry_after seconds or use the standard Retry-After response header.

Context too long

400 context_length_exceeded is not fixed by sending the same request again. Shorten the input or let the user choose a model with a larger context window.

Find the right API format

Read tokenlab.accepted_request_formats from GET /v1/models/{model} before using a model-specific API. An accepted format confirms the endpoint. Individual tools and fields can still vary by model; check the model page before depending on them.

Find a model by task

The Models API can return a current shortlist for non-chat tasks:
Valid recommended_for values are image, video, music, 3d, tts, stt, embedding, rerank, and translation. Send the chosen model ID explicitly in the create request. TokenLab does not silently replace it with a different model.

Machine-readable overview

Agents can read a compact API overview at:
It includes a first request, common endpoints, model filters, and error-handling guidance.

Safe retry example

This example corrects a model name only when the API returns did_you_mean. Add user confirmation if changing models can alter quality, price, or data handling in your product.