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 happened | Charged? |
|---|---|
| The provider returned an error (5xx), or timed out, and no other route could answer | No |
| The model returned an empty reply (no output at all) | No |
| A stream died before any output reached you | No |
| A stream was cut after some output was produced | It 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 partway | Yes, 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.
| Status | Type | What it means | What to do |
|---|---|---|---|
400 | invalid_request_error | The request body is wrong, or the model does not support that endpoint or parameter | Read error.message, fix the payload. Do not retry unchanged |
401 | authentication_error | Key missing, invalid, expired or disabled | Fix the key |
402 | insufficient_quota | Wallet is empty, or this key reached its own budget | Top up or raise the key budget |
403 | forbidden | The 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 |
404 | code model_not_found | "Model '...' is not available." The id is wrong, or the model is not offered | Copy the id from the models page. Check GET /v1/models |
413 | request_too_large | Body is over the 10 MB limit | Send less data |
429 | rate_limit_error | Too many requests per minute, or too many at once | Back off and retry |
500 | internal_server_error | Unexpected error on our side | Retry with a short wait |
502 | upstream_error | Every provider route for the model failed | Retry after a few seconds. Not billed |
503 | service_unavailable | "No configured providers available for this model" | Try another model for now. Retrying the same model will not help |
504 | gateway_timeout | The provider did not answer in time | Retry. 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.