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.

StatuserrorMeaningWhat to do
400bad_requestMalformed body or fieldFix the request
400tools_unsupportedNo model of the tier can use toolsUse another tier
400unknown_tierThe tier does not exist; tiers lists known onesFix the request
401unauthorizedMissing or wrong keyCheck the key
404not_foundUnknown route, or another product's video task
413too_largeBody over the route's limitSend less
429budget_exhaustedA daily limit is closedHand over to a person
500internalUnhandled errorRetry later
502, 504upstream, upstream_error, timeoutA model or server failedRetry later
503all_rungs_failedNo rung answered; attempts shows whyUse your fail-safe, retry later
503not_configuredThe route is not set up
503model_unavailableThe embeddings model is not availableRetry later

Python client exceptions#

All derive from BlackgateError and have a retryable flag.

ExceptionCauseRetryable
BudgetExhausted (scope, used, cap)429No
AllRungsFailed (attempts)503Yes
UnknownTier (tiers), BadRequest, Unauthorized400 and 401No
BlackgateTimeoutClient timeout; the call may already be countedYes
BlackgateUnavailableNetwork failureYes
UnexpectedResponseOther 5xx or a non-JSON answerYes for 5xx