Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Errors and limits

Error shape

Errors Model Gateway raises are JSON with one field:

{"error": "spend grant limit would be exceeded"}
  • 401 is always {"error":"unauthorized"} and 403 is always {"error":"forbidden"}. Neither says why.
  • Every 5xx, 503 included, is {"error":"internal error"}; details are kept out of responses.
  • Other 4xx messages are written for people and may change. There are no error codes.
curl -sS https://gqbzygqa4dd3t54xnb2fg5wcou0pitmm.lambda-url.us-east-1.on.aws/v1/model-gateway/custom-adapters | grep -Fx '{"error":"unauthorized"}'

Some errors are not JSON. They come from request parsing, which happens only after Model Gateway has accepted your credential (a request without one gets 401 whatever its body), and are plain text:

StatusCauseExample body
400A path id is not a UUID, or the body is not valid JSONInvalid URL: Cannot parse `credential_id` with value `not-a-uuid`: ...
413Body larger than 2 MiBFailed to buffer the request body: length limit exceeded
415Body sent without Content-Type: application/jsonExpected request with `Content-Type: application/json`
422Body is JSON but a required field is missing or has the wrong typeFailed to deserialize the JSON body into the target type: missing field `api_key` ...

Status codes

StatusMeaning
200, 201, 204Done. Creating returns 201; deleting and revoking return 204.
400A field breaks a rule: see the tables in API examples. Also a credential for a provider that is neither built in nor one of the person’s custom adapters, a model call that names no spend grant, or one on a custom-provider credential created before credentials carried a destination (2026-11-14).
401No token, a token ChirpAuth doesn’t verify, or a missing or invalid x-user-id.
403A person’s sign-in token; a missing or malformed x-granite-grant; a Granite grant Granite doesn’t approve; a model call on a spend grant Granite doesn’t approve for the calling agent, or one revoked in Granite.
404No such credential or adapter for this person, including a model call on a spend grant whose credential was deleted. Another person’s records read as 404 too.
409A custom adapter with that name exists, or a spend grant has no units left.
413, 415, 422Parsing errors; see above.
500Something failed inside Model Gateway.
503Granite could not be reached. Retry later.

Rate limits

Model Gateway sets no rate limits or quotas of its own.

Size limits

LimitValue
Request body2 MiB
x-user-id128 characters
provider, label, adapter name128 characters
api_key8 to 4096 characters