ModelGo API Errors, Rate Limits & Retries

Error shape

The outer structure of an error body follows the inbound protocol you called, so official SDKs can parse it directly:

  • OpenAI-style endpoints (/v1/chat/completions, /v1/responses, /v1/embeddings, /v1/images/*, /v1/audio/*, and so on) return the OpenAI error format;
  • the Anthropic endpoint (/v1/messages) returns the Anthropic error format;
  • other endpoints (async tasks, Rerank, vendor-native protocols, and so on) return the platform's generic format {"error":{"code","message","metadata"},"trace_id"}.

For example, on an OpenAI-style endpoint:

json
{
  "error": {
    "message": "unauthorized",
    "type": "invalid_request_error",
    "param": null,
    "code": 401,
    "metadata": {
      "app_error_id": 4011,
      "error_class": "auth",
      "request_id": "gw_784d4712-88d0-43d9-adea-7d7208838ec1"
    }
  },
  "trace_id": "0cf72aa7cf62cf4fa3276da9a066427b"
}
  • The gateway writes error messages in English in every market. For managed API failures, including failed async tasks, Chinese upstream error text is summarized in English. On routes that forward responses directly, the upstream service supplies the response text.
  • Decide what went wrong from the HTTP status and metadata.error_class. When present, metadata.reason gives a more specific reason.
  • When contacting support, include the X-Request-ID response header (the same value as metadata.request_id).

Common errors

HTTPerror_classWhat to do
400client_invalidCheck the request format and parameters; the request body limit is 10 MiB
400model_protocol_not_offeredThe model is not offered on this endpoint; switch endpoint or model (see the protocols listed in the Model Catalog)
400provider_invalid, provider_context_length_exceeded, provider_output_cap_exhaustedThe upstream rejected a parameter, the input exceeds the context window, or the output limit is too small; adjust according to message and retry
401authCheck the API key
402billing_insufficient and the quota / budget limitsTop up, or adjust the API key quota and budgets in the console
403policy, account_suspendedNot allowed to call this model, or the account is restricted; see metadata.reason
429quota, provider_rate_limitPlatform or upstream rate limit; back off and retry
5xxTemporary platform or upstream failure (including 504 provider_timeout)Back off and retry; contact support if it persists

When metadata.reason is reservation_exceeds_funds, your available balance and credit cannot cover the requested reservation. Reduce the size of your request or add funds before retrying.

Rate limits and retries

  • When metadata.reason is free_model_daily_limit_reached, wait for your daily free-model allowance to reset before retrying.
  • 429 and 503 are retryable. If the response carries Retry-After, wait that long; otherwise use exponential backoff.
  • When retrying a non-streaming request, send an Idempotency-Key header: retrying the same request with the same key returns the first successful result without charging again; the same key with a different body returns 422. Streaming requests and multipart uploads are not covered.
  • An error that happens after a streaming response has started does not change the HTTP status; it arrives as an error event inside the stream, and should be treated as a failure.

Are failed requests billed?

  • Rejected before being sent upstream (parameters, authentication, permissions, quota, balance, and so on): not billed.
  • Successful requests, and streaming requests that already delivered part of the output: billed on actual usage.
  • Processed by the upstream but failed in the end: may be billed at the amount reserved for the request; failures caused on the platform side, or where the upstream never responded, are not billed.
  • Disconnecting the client does not cancel a request that was already sent upstream; it is still billed normally.
  • Failed async tasks such as video generation are not billed.

Errors specific to an endpoint are described on its capability page.