Error Handling

Tchavi returns standard HTTP status codes with a structured JSON error body.

Tchavi returns standard HTTP status codes. Errors include a flat JSON body — the machine-readable code is in error, and some codes add a details object:

JSON
{
  "error": "insufficient_credits",
  "message": "You don't have enough credits for this request.",
  "statusCode": 402,
  "details": { "credits_remaining": 12, "credits_required": 40 }
}

Common error codes

StatusCodeDescription
400bad_requestInvalid parameter — the message says which one
401invalid_api_keyMissing or invalid API key
402insufficient_creditsNot enough credits — details carries credits_remaining and, when known, credits_required
403key_inactiveThe key is revoked, suspended or expired — details.status says which
403plan_model_restrictedFree-level account calling a model outside the Budget group — top up to unlock it (details.upgrade_url)
403model_not_allowedThe model is not available (inactive or unknown)
403forbiddenThe key's IP allow-list or endpoint restrictions reject this request
404not_foundUnknown model ID or job ID
413prompt_too_longPrompt exceeds this model's limit — see below
429rate_limit_exceededRPM, TPM or IP limit reached — wait for Retry-After seconds (also in details.retry_after)
429free_tier_daily_limitFree-level daily cap (50 requests) reached — resets at midnight UTC, Retry-After says when
500internal_errorServer error — retry or contact support
502provider_errorThe AI provider returned an error — retry, or try another model
503provider_saturatedThe provider is at capacity — retry after details.retry_after seconds
503service_unavailableTemporary outage — retry with backoff

Prompt length limits

A few models accept a smaller prompt than their underlying context window, because the provider charges a higher rate above a threshold and we cap the window rather than raise the credit rate for everyone. Those models return 413 prompt_too_long, with the exact ceiling in the response so you can split the input without guessing:

JSON
{
  "error": "prompt_too_long",
  "message": "Prompt is too long for \"grok-4.6\". This model accepts up to 180000 tokens of input; your request is about 241300.",
  "statusCode": 413,
  "details": { "model": "grok-4.6", "max_prompt_tokens": 180000 }
}
ModelPrompt limit
grok-4.6180 000 tokens
gemini-3.1-pro180 000 tokens
qwen3.7-flash230 000 tokens

max_prompt_tokens is the limit we actually enforce, and it matches the context window shown on each model's page — a request trimmed to it is accepted. Every other model accepts input up to its full context window. Base64 images and PDFs do not count toward the limit.

See also Rate Limits and Credits & Billing.

On this page