Errors and rules
Error codes
Common HTTP status codes and error messages from the goodapi API, how to fix them, and the request ID to give support.
Updated
When a request fails, start with the HTTP status code and error message and look them up below. If you can't resolve it, send support the request ID at the end of the error message.
Error format
The OpenAI-format endpoints return errors like this:
{
"error": {
"code": "",
"message": "Invalid token (request id: 20261121035941044595246...)",
"type": "new_api_error"
}
}The Anthropic-format endpoint (/v1/messages) returns:
{
"type": "error",
"error": {
"type": "...",
"message": "... (request id: ...)"
}
}The (request id: ...) at the end of the message is this request's ID, the same as the x-oneapi-request-id response header. Include it when you contact support.
Error messages are in Chinese by default. Send the Accept-Language: en request header to get them in English. The table below gives both versions.
Status codes
| Status | Cause | Error message | What to do |
|---|---|---|---|
| 400 | The body isn't valid JSON, or a parameter has the wrong type (for example a negative max_tokens) |
Invalid request: invalid JSON request body (无效的请求,…); for wrong types, the specific parse error |
Check the request body |
| 401 | No key, wrong key, key disabled or expired, or key quota used up | Invalid token (无效的令牌) |
See 401 |
| 403 | The model isn't in the key's group or model limits, or the model name doesn't exist | This token has no access to model xxx (该令牌无权访问模型 xxx) |
Check the model name and key group; see 403 |
403 insufficient_user_quota |
Account balance too low | Insufficient user quota, remaining quota: … (用户额度不足, 剩余额度: …) |
Top up on the Wallet page in the console |
403 request_blocked |
A refused request was resent unchanged within 24 hours, or the model (or all models) is suspended for violations | Explanation in both Chinese and English | See Content policy |
403 violation_rate_limited |
Rate-limited after violations | Explanation in both Chinese and English | See Content policy |
| 429 | Too many requests; rate-limited by the model provider | — | Wait and retry, and lower your concurrency |
| 503 | The model is temporarily unavailable | — | Retry later |
401: Invalid token
All of the following return 401 Invalid token, with the same message:
- The request has no key, or the header is wrong. The OpenAI format uses
Authorization: Bearer sk-...;/v1/messagesalso acceptsx-api-key. - The key was copied incompletely, or has been deleted or disabled.
- The key has expired.
- The key's quota is used up. (This is different from a low account balance, which returns 403.)
Check the key's status, expiry and remaining quota on the API Keys page of the console.
403: This token has no access to model
A model name that doesn't exist and a model the key isn't allowed to use return the same error. Check, in order:
- Is the model name spelled correctly, and is it listed in Models and pricing?
- Is the model in the key's group? A key can only call models in its own group; see API keys.
- If the key has model limits enabled, is the model on the list?
GET /v1/models lists exactly the models the current key can use.
Content policy
A model refusal on content-policy grounds, or a request blocked by content moderation, counts as a violation. It incurs a content violation fee, and repeated violations lead to escalating restrictions:
request_blocked: a refused request resent unchanged within 24 hours returns this error right away. It isn't charged and isn't sent to the model; change the request and try again. The same error is returned when a model, or every model on the account, is suspended after repeated violations.violation_rate_limited: after several violations on the same model in a short time, that model is limited to 1 concurrent request and 10 requests per minute, and anything beyond that returns this error. The limit usually lifts automatically 1–2 hours after the violations stop.
To recognize a refusal, see Model refusals. For the full rules, see Violations and restrictions.
429 and 503
- 429: too many requests; the model provider is rate-limiting you. Wait a few seconds, retry, and lower your concurrency.
- 503: the model is temporarily unavailable. Retry later.
Ordinary failures such as rate limits and timeouts never incur a content violation fee. If an error keeps happening, send the request ID to support.