Tolka Edge SymbolTolka Edge WordmarkDocs

Errors & Status Codes

The Tolka Edge error envelope, every error code, and how to handle AI Rig timeouts and limits.

Tolka Edge mirrors OpenAI's error envelope and adds a tolka_details object so your applications can make precise, automated decisions.

Error envelope

{
  "error": {
    "message": "Insufficient balance to route request.",
    "type": "payment_required",
    "code": "insufficient_balance",
    "param": "wallet",
    "tolka_details": {
      "balance_paise": 0,
      "required_paise_for_model": 400
    }
  }
}
ParameterTypeDescription
messagestringHuman-readable explanation.
typestringBroad error category, e.g. payment_required, gateway_timeout.
codestringStable machine-readable code — branch your retry logic on this.
paramstring | nullThe offending field, when applicable.
tolka_detailsobjectTolka-specific context such as wallet balances or limits.

Status codes

StatuscodeMeaningRetryable
400validation_errorMalformed request body or missing model.No
401auth_errorMissing or invalid API key.No
402insufficient_balanceWallet can't cover the request.After top-up
403upi_verification_requiredAccount not UPI-verified.After verification
502proxy_errorGateway failed to connect to the Rig.Yes
504node_boot_timeoutThe background boot of the AI Rig timed out.Yes, after 30s

Handling errors in code

from openai import OpenAI, APIStatusError
import os
 
client = OpenAI(base_url="https://api.tolkaedge.com/v1", api_key=os.environ.get("TOLKA_API_KEY"))
 
try:
    resp = client.chat.completions.create(
        model="Qwen/Qwen3-14B",
        messages=[{"role": "user", "content": "Hi"}],
    )
except APIStatusError as e:
    # 402 Payment Required
    if e.status_code == 402:
        print("Please top up your wallet!")
    # 504 Node Boot Timeout
    elif e.status_code == 504:
        print("Rig is taking too long to boot. Please retry.")
    else:
        print(f"Error {e.status_code}: {e.response.json()}")