Status Code Mapping

Chuizi.AI acts as a gateway between your application and upstream AI providers. When a provider returns an error, the gateway maps it to a consistent, OpenAI-compatible error format. This page documents how upstream errors are translated.

Mapping Principle

All upstream errors are normalized to the Chuizi.AI error format. Your application only needs to handle one error schema regardless of which provider processes the request.

Upstream Provider Error → Chuizi.AI Gateway → OpenAI-Compatible Error Response

The original provider error details are logged server-side with the X-Request-Id for debugging but are never exposed to the client.

General Mapping Rules

Upstream StatusGateway StatusError CodeError TypeDescription
400400bad_requestinvalid_request_errorProvider rejected the request as malformed.
401502provider_errorupstream_errorUpstream auth failure (gateway key issue, not your key).
403502provider_errorupstream_errorUpstream permission denied (gateway account issue).
404404model_not_foundnot_foundModel does not exist at the upstream provider.
429429rate_limit_exceededrate_limit_errorUpstream provider rate limit hit. Gateway returns Retry-After.
500502provider_errorupstream_errorUpstream internal error.
502502provider_errorupstream_errorUpstream bad gateway.
503503provider_unavailableservice_unavailableUpstream service is down or overloaded.
504504provider_timeouttimeout_errorUpstream did not respond in time.
Connection refused503provider_unavailableservice_unavailableUpstream host is unreachable.
DNS failure503provider_unavailableservice_unavailableUpstream hostname cannot be resolved.
TLS error503provider_unavailableservice_unavailableTLS handshake with upstream failed.
Request timeout504provider_timeouttimeout_errorGateway's own timeout exceeded waiting for upstream.

Next Steps