API Reference

Error Codes

Complete reference for every error code the TokSpan API can return, with descriptions and troubleshooting steps.

HTTP Status Codes

CodeMeaningAction
400Bad RequestCheck your request body for malformed JSON or missing required fields
401UnauthorizedVerify your API key is correct and active in the dashboard
404Invalid URL / Endpoint Not FoundCheck the request path against the API reference
429Rate Limited / Insufficient QuotaFor rate limits, implement exponential backoff with jitter. If the error mentions quota or balance (e.g. insufficient_user_quota), top up in the Dashboard instead of retrying — see rate limits
500Internal ErrorTokSpan-side issue — retry with backoff or contact support
502Bad GatewayUpstream provider error — auto-failover may activate
503Service Unavailable / Model Not FoundTemporary overload — retry with backoff. If the error carries code model_not_found, the model isn't available to your key — check the model name in the model catalog

Error Response Format

Errors are returned with an error object containing a human-readable message and a type identifier. On TokSpan the type is usually new_api_error, and account-balance errors carry code: "insufficient_user_quota". Example:

json
{
  "error": {
    "message": "You can access all models, but this request exceeded your account balance. Please top up at the Dashboard.",
    "type": "new_api_error",
    "param": null,
    "code": "insufficient_user_quota"
  }
}

Checking the message matters. A 429 with a rate-limit message means back off and retry; a 429 (or 400) with a quota message means add credits first. Read the message before deciding how to react. The message wording shown here is illustrative — always rely on the HTTP status code and the code field.