Skip to main content

Common Errors and Troubleshooting

When encountering errors while calling the API, you can quickly diagnose the issue using the returned HTTP status code and the error.message in the response body.


Common HTTP Status Codes​

1. 401 Unauthorized (Authentication Failed / Invalid Key)​

Typical Response:

{
"error": {
"message": "Incorrect API key provided: sk-***",
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}

Troubleshooting Checklist:

  • Check whether the Authorization: Bearer sk-... request header is formatted correctly and whether any accidental spaces or newlines were copied around the key.
  • Verify in "Console - API Keys" whether the token has been disabled or deleted.
  • Confirm whether the token in use has IP whitelisting configured or is restricted to specific models.

2. 429 Too Many Requests / Insufficient Quota (Quota Exceeded / Rate Limited)​

Possible Causes and Solutions:

  1. Account or Token Quota Exhausted (Insufficient Quota):
    • Check your total account balance in the "User Console".
    • Check whether the API Key being used has a dedicated quota limit configured that has been reached.
  2. Request Rate or Concurrency Limit Exceeded (Rate Limit Exceeded):
    • High-concurrency burst requests were sent from the client in a short period.
    • It is recommended to implement exponential backoff retries in your client code. If you require higher enterprise-level concurrency, please submit a ticket in the Support Center.

3. 404 Model Not Found (Model Not Found)​

Possible Causes and Solutions:

  • The model field in the request body is misspelled (e.g., mistyping gpt-4o as gpt4o).
  • Confirm that the model is currently available on the platform (you can check the Model Square).

4. 500 / 502 / 504 Gateway Error (Upstream Channel Error)​

Possible Causes and Solutions:

  • The upstream official model provider (e.g., OpenAI, Anthropic) experienced a service outage or network instability.
  • Ainfix features built-in multi-channel smart retries and automatic failover, handling most network fluctuations seamlessly within the platform. If errors persist across a wide scale, please check the platform status or submit a ticket in the Support Center.