DocsAPI Reference
API Guides

Errors and debugging

Understand API errors and collect the details needed to troubleshoot a request.


Check the HTTP status and error body first. For a stream, also check for an error event or an incomplete response after streaming begins.

Common problems

ProblemWhat to check
Cannot connectAPI hostname, network and client timeout
Authentication rejectedKey header, expiry, disabled/revoked state and environment
Request forbiddenInference key type and its organization binding
Credit or usage-limit refusalWorkspace credit and applicable usage limits
Model or parameter rejectedExact model ID, selected endpoint and supported fields
Provider errorReturned error details; retry only when appropriate
Stream ends unexpectedlyError events, cancellation and connection loss

Find model IDs through Models. The chosen model must support the request format.

Capture response headers

This Bash example saves the headers from a model-list request:

curl -sS -D response-headers.txt \
  https://api.tokamak.sh/v1/models \
  -H "Authorization: Bearer $TOKAMAK_API_KEY"

Add the same -D response-headers.txt option to an inference request when debugging it.

HeaderUse
X-Request-IdHTTP request correlation, when returned
X-Tokamak-Execution-IdInference execution identifier for usage lookup, when returned

A request rejected before inference admission may have no execution ID. Provider IDs inside the response are separate from Tokamak's execution ID.

Check a completed request

Save the execution ID as EXECUTION_ID, then query:

curl -sS --get https://api.tokamak.sh/v1/generation \
  -H "Authorization: Bearer $TOKAMAK_API_KEY" \
  --data-urlencode "id=$EXECUTION_ID"

The response includes usage and billing status when available. Settlement can still be pending; see Usage.

Retry carefully

Use bounded retries with backoff for transient failures. Correct invalid credentials or request parameters before retrying.

A new inference POST can perform new work and create another charge. The optional X-Client-Request-Id header helps correlate requests; it does not prevent duplicate execution.

For streams, HTTP success means the stream started. Handle its terminal and error events as described in Streaming.

Ask for help

Share the API environment, UTC timestamp, model, endpoint, status/error code, and available request and execution IDs. Redact API keys, authorization headers, cookies and private prompt content.

On this page