[API reference]

Errors

Topo uses standard HTTP status codes and returns errors in the OpenAI shape, with a stable type to branch on and a request ID for support.

Error shape

error.json
json
{  "error": {    "type": "insufficient_balance",    "message": "Wallet balance 0.0021 USDT is below the estimated cost 0.0041 USDT.",    "param": null,    "request_id": "req_7Hq2kf91"  }}

Error codes

StatusTypeWhat happenedRetry
400invalid_requestThe body is malformed or a parameter is out of range.No
401invalid_api_keyThe key is missing, revoked or mistyped.No
402insufficient_balanceThe wallet cannot cover the estimated cost. Top up or lower max_tokens.After top-up
402spend_limit_reachedThe key or agent wallet hit its spend limit.No
403key_scope_violationThe model, region or IP is outside the key's scope.No
404model_not_foundNo model with that ID, or it is not enabled on your plan.No
409idempotency_conflictAn Idempotency-Key was reused with a different body.No
429rate_limitedToo many requests or tokens per minute. Wait for retry-after.Yes
500internal_errorUnexpected error in the router.Yes
502node_unavailableThe node dropped mid-request. Topo already retried once on another node.Yes
503capacity_exhaustedNo healthy capacity for the model. Add a topo.fallback.Yes
504node_timeoutNo first token arrived in time.Yes

Retries

Retry 429 and 5xx responses with exponential backoff and jitter, and send the same Idempotency-Key on every attempt. A request is settled at most once per key, even when several attempts reach a node.

import osimport uuidfrom openai import OpenAI client = OpenAI(    base_url="https://api.topolabs.ai/v1",    api_key=os.environ["TOPO_API_KEY"],    max_retries=4,  # backoff with jitter on 429 and 5xx) response = client.chat.completions.create(    model="claude-sonnet-5.5",    messages=[{"role": "user", "content": "Summarize this ticket"}],    extra_headers={"Idempotency-Key": str(uuid.uuid4())},)