Daily limits and errors
Daily limits#
Text, image and video requests count against two limits per UTC day:
- A product limit, shared by all calls with your key.
- A per-client limit, for calls that carry a
subject.
Without a subject only the product limit applies. Defaults are 2000 a day per product and 300 a day per client; the operator can change them. GET /v1/usage returns your count and limit.
Limits are counted before the call, so a request that fails halfway still used its share. Embeddings and speech are not counted.
When a limit is reached the answer is 429 budget_exhausted with scope (product or subject), used, cap and, for text, degrade: "human_handoff". Hand the conversation to a person instead of showing an error, and do not bill your customer for it. The answer stays the same until the next UTC day. A limit is never reported as 402.
Errors#
Error bodies look like {"error": "<code>", "detail": "<text>"}. The code is stable; the text is not.
| Status | error | Meaning | What to do |
|---|---|---|---|
| 400 | bad_request | Malformed body or field | Fix the request |
| 400 | tools_unsupported | No model of the tier can use tools | Use another tier |
| 400 | unknown_tier | The tier does not exist; tiers lists known ones | Fix the request |
| 401 | unauthorized | Missing or wrong key | Check the key |
| 404 | not_found | Unknown route, or another product's video task | |
| 413 | too_large | Body over the route's limit | Send less |
| 429 | budget_exhausted | A daily limit is closed | Hand over to a person |
| 500 | internal | Unhandled error | Retry later |
| 502, 504 | upstream, upstream_error, timeout | A model or server failed | Retry later |
| 503 | all_rungs_failed | No rung answered; attempts shows why | Use your fail-safe, retry later |
| 503 | not_configured | The route is not set up | |
| 503 | model_unavailable | The embeddings model is not available | Retry later |
Python client exceptions#
All derive from BlackgateError and have a retryable flag.
| Exception | Cause | Retryable |
|---|---|---|
BudgetExhausted (scope, used, cap) | 429 | No |
AllRungsFailed (attempts) | 503 | Yes |
UnknownTier (tiers), BadRequest, Unauthorized | 400 and 401 | No |
BlackgateTimeout | Client timeout; the call may already be counted | Yes |
BlackgateUnavailable | Network failure | Yes |
UnexpectedResponse | Other 5xx or a non-JSON answer | Yes for 5xx |