Errors and retries
GM returns the error envelope native to the compatibility surface where possible. Use the HTTP status first, then inspect the structured error body.
| Status | Typical meaning | Retry? |
|---|---|---|
400 |
Invalid or unsupported request | No; change the request. |
401 |
Missing or invalid API key | No; replace or fix the key. |
402 |
Insufficient prepaid credit | No; add credit first. |
404 |
Model does not exist in the public catalog | No; choose another model. |
429 |
Rate or capacity limit | Yes, with backoff. |
500 |
Unexpected gateway or upstream failure | Usually, with a bounded retry. |
502 / 503 |
Upstream or routing availability failure | Yes, with backoff or another model. |
504 |
Upstream timeout | Yes, but account for possible prior processing. |
Error body
Section titled “Error body”On OpenAI-compatible routes the body wraps a single error object. A request
sent without a usable API key returns HTTP 401 and:
{ "error": { "message": "Invalid Authentication", "type": "invalid_request_error", "code": "invalid_api_key", "param": null }}Requesting a model that is not in the public catalog returns HTTP 404 and the
same envelope with "code": "model_not_found".
Branch on error.code, not on error.message. Message text is written for
humans and can change; param is populated only when a specific request field
caused the failure.
An empty list is not an error
Section titled “An empty list is not an error”Filtering the catalog with an unrecognized value returns HTTP 200 and an empty
list rather than a 400:
curl -fsSL "https://api.saygm.com/v1/models?api_shape=does-not-exist"{ "object": "list", "data": [] }An unrecognized query parameter name is ignored outright, so the response is the
unfiltered catalog. If your application discovers models at startup, treat an
empty data list as a configuration error and fail loudly. A silent empty
result is otherwise indistinguishable from an outage. Valid api_shape values
are listed under choose a model.
Retry policy
Section titled “Retry policy”For retryable failures:
- Honor
Retry-Afterwhen present. - Use exponential backoff with jitter.
- Cap both attempts and total elapsed time.
- Avoid automatic retries after a streaming response has emitted content.
- Log a request identifier and status, never the API key or sensitive prompt.
The available field in /v1/models is advisory. A model can change state
after discovery, so callers must still handle a routing failure.