Errors and status codes
One error shape, what each code means, and how each SDK raises it.
Every error has the same shape, whether the gateway or Catalyst produced it. Read error.code, and retry only when error.retryable is true (honour Retry-After). Every response carries X-Request-Id; quote it when you contact support.
{ "success": false, "request_id": "req_0123456789abcdef0123", "service": "gateway", "session_id": null,
"status": "failed", "data": null, "files": [], "usage": { "plumes": 0 },
"error": { "code": "QUOTA_EXCEEDED", "message": "This API user has run out of PLUMES.", "retryable": false,
"details": { "balance": 0, "required": 1, "unit": "PLUMES" } } }| error.code | Status | Retryable |
|---|---|---|
UNAUTHORIZED | 401 | no |
KEY_EXPIRED | 401 | no |
QUOTA_EXCEEDED | 402 | no |
ACCOUNT_PENDING | 403 | no |
NOT_FOUND | 404 | no |
INVALID_REQUEST | 400 / 422 | no |
RATE_LIMITED | 429 | yes |
CONCURRENCY_LIMIT | 429 | yes |
UPSTREAM_UNAVAILABLE | 502 / 503 | yes |
INTERNAL | 500 | no |
The SDKs add one code of their own, TOOL_REJECTED (status 422, never retried): the API accepted a client-tool registration but refused some of the tools in it, and the SDK raises so the mistake is not silent. See Client tools.
One example of each
These are the gateway's own answers, recorded from its error builders (request_id is different on every call). 402 QUOTA_EXCEEDED is shown at the top of this page. The 429 answers also send a Retry-After header with the number of seconds.
401 UNAUTHORIZED
{
"success": false,
"request_id": "req_0123456789abcdef0123",
"service": "gateway",
"session_id": null,
"status": "failed",
"data": null,
"files": [],
"usage": {
"plumes": 0
},
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or revoked API key.",
"retryable": false
}
}401 KEY_EXPIRED
{
"success": false,
"request_id": "req_0123456789abcdef0123",
"service": "gateway",
"session_id": null,
"status": "failed",
"data": null,
"files": [],
"usage": {
"plumes": 0
},
"error": {
"code": "KEY_EXPIRED",
"message": "This API key has expired. Ask your administrator for a new key or a new expiry date.",
"retryable": false
}
}403 ACCOUNT_PENDING
{
"success": false,
"request_id": "req_0123456789abcdef0123",
"service": "gateway",
"session_id": null,
"status": "failed",
"data": null,
"files": [],
"usage": {
"plumes": 0
},
"error": {
"code": "ACCOUNT_PENDING",
"message": "This API key is not connected to Catalyst yet. Contact your administrator.",
"retryable": false
}
}429 RATE_LIMITED
{
"success": false,
"request_id": "req_0123456789abcdef0123",
"service": "gateway",
"session_id": null,
"status": "failed",
"data": null,
"files": [],
"usage": {
"plumes": 0
},
"error": {
"code": "RATE_LIMITED",
"message": "Request limit of 60 per minute reached.",
"retryable": true,
"details": {
"scope": "requests_per_minute",
"limit": 60,
"retry_after_seconds": 5
}
}
}429 CONCURRENCY_LIMIT
{
"success": false,
"request_id": "req_0123456789abcdef0123",
"service": "gateway",
"session_id": null,
"status": "failed",
"data": null,
"files": [],
"usage": {
"plumes": 0
},
"error": {
"code": "CONCURRENCY_LIMIT",
"message": "This key allows 4 requests at the same time. Wait for one to finish.",
"retryable": true,
"details": {
"scope": "concurrent_requests",
"limit": 4,
"retry_after_seconds": 1
}
}
}502 UPSTREAM_UNAVAILABLE
{
"success": false,
"request_id": "req_0123456789abcdef0123",
"service": "gateway",
"session_id": null,
"status": "failed",
"data": null,
"files": [],
"usage": {
"plumes": 0
},
"error": {
"code": "UPSTREAM_UNAVAILABLE",
"message": "The upstream request failed.",
"retryable": true
}
}How each SDK raises them
Branch on the kind or the code, never on the message text.
| Situation | Python / TypeScript | Rust (`ErrorKind`) |
|---|---|---|
| Bad input (also caught locally, before sending) | InvalidRequestError | InvalidRequest |
| Wrong, revoked or expired key | AuthenticationError | Authentication |
| Balance used up (never retried) | QuotaExceededError | QuotaExceeded |
| Missing scope, IP not allowed, account pending | PermissionDeniedError | PermissionDenied |
| Not found | NotFoundError | NotFound |
| Idempotency key reused with a different request | ConflictError | Conflict |
| Rate or concurrency limit (has retry-after) | RateLimitError | RateLimit |
| 5xx, or a service behind the API failed | InternalServerError, UpstreamError | InternalServer, Upstream |
| Could not reach the server / timed out | APIConnectionError, APITimeoutError | Error::Connection, Error::Timeout |
from falcore import (AuthenticationError, QuotaExceededError, RateLimitError,
InvalidRequestError, APIConnectionError, APIStatusError)
try:
song = catalyst.composer.compose("calm piano")
except InvalidRequestError as e: print("fix the request:", e.details)
except AuthenticationError as e: print("check your key:", e.code)
except QuotaExceededError as e: print("out of plumes:", e.details)
except RateLimitError as e: print("slow down for", e.retry_after, "seconds")
except APIConnectionError: print("network problem; safe to retry")
except APIStatusError as e: print(e.status, e.code, e.request_id)An error never contains your key.