Skip to main content
APITroubleshooting

Why a call failed, and whether you were charged

What each AICredits error code means, what to do about it, and which failed or cancelled requests are billed. Covers 4xx, 5xx, timeouts, empty replies and cancelled streams.

Use this page with an AI assistant

Opens a new chat with this docs URL and the correct AICredits base URLs.

When a request fails, two questions matter: what went wrong, and did money leave your wallet. This page answers both.

Were you charged?

What happenedCharged?
The provider returned an error (5xx), or timed out, and no other route could answerNo
The model returned an empty reply (no output at all)No
A stream died before any output reached youNo
A stream was cut after some output was producedIt depends. Most are logged as failed with a zero charge, but a cut stream that did deliver output can be billed. Check the request in Dashboard → Usage
You cancelled or disconnected partwayYes, for what was generated up to that point
401 (bad or missing key)No. See 401: Invalid API key

If you cancel a streaming request, you pay for the output that was already generated. If you cancel a non-streaming request, you may be charged for the input only. Cancelling early keeps the cost small, but it is not zero.

If a request failed and the wallet still dropped, open the request in Dashboard → Usage, note its time, model and state, and write to support with those details. See Reading your usage and charges.

Error codes

Errors use the same JSON shape on every endpoint (the Messages API at /v1/messages uses Anthropic's shape, with the same status codes). See Error handling for the full format.

StatusTypeWhat it meansWhat to do
400invalid_request_errorThe request body is wrong, or the model does not support that endpoint or parameterRead error.message, fix the payload. Do not retry unchanged
401authentication_errorKey missing, invalid, expired or disabledFix the key
402insufficient_quotaWallet is empty, or this key reached its own budgetTop up or raise the key budget
403forbiddenThe key is valid but not allowed to do this, for example: "This API key is not permitted to use model ..."Edit the key's allowed models in Dashboard → API Keys, or use another key
404code model_not_found"Model '...' is not available." The id is wrong, or the model is not offeredCopy the id from the models page. Check GET /v1/models
413request_too_largeBody is over the 10 MB limitSend less data
429rate_limit_errorToo many requests per minute, or too many at onceBack off and retry
500internal_server_errorUnexpected error on our sideRetry with a short wait
502upstream_errorEvery provider route for the model failedRetry after a few seconds. Not billed
503service_unavailable"No configured providers available for this model"Try another model for now. Retrying the same model will not help
504gateway_timeoutThe provider did not answer in timeRetry. For long answers use streaming

Quick checks

Run this to see the status code and the error message together:

curl -i https://api.aicredits.in/v1/chat/completions \
  -H "Authorization: Bearer sk-your-key-here" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-6.1-sol", "messages": [{"role": "user", "content": "Hi"}]}'

The first line (HTTP/2 404, HTTP/2 402 and so on) is the status. The JSON body has the reason in error.message.

Check your balance without opening the dashboard:

curl https://api.aicredits.in/v1/credits \
  -H "Authorization: Bearer sk-your-key-here"

Retrying safely

Retry 429, 500, 502 and 504 with a growing wait (1 s, 2 s, 4 s). Do not retry 400, 401, 402, 403, 404 or 503 without changing something first. A failed attempt that is not billed costs you nothing, so retrying these codes does not add charges. A retry that succeeds is billed once, for that successful call. A copy-paste retry loop is in Error handling.