Skip to main content
Docs

One endpoint,
every model.

Tare is an OpenAI-compatible gateway in front of every model you use — ours and the ones you bring yourself. One base URL, one key, and every token accounted for.

OperationsErrors

Errors

What this solves: When a call fails, how to locate the cause in a fixed order; and how to explain a failure to an end user without misleading them.

When a call fails, locate the cause in the order below. When you need to relay the cause to an end user, use the same set of judgments.

What you need to know first: The error body has the OpenAI shape ({"error": {"message": …, "type": …}}), and that is the shape SDKs read. With any other shape, your client logs degrade to an undefined line.

Triage order: status code first, then code / type, then refusal_reason

Don't look at the HTTP status code alone. The same 403 can come from key type, quota, source IP, DLP, budget, and other reasons, so you have to look two levels deeper.

OrderWhich cell to look atWhat it answers
1HTTP status codeWhich broad category the failure belongs to (credential / permission / not found / rate limit / upstream / platform)
2error.code / error.typecode is always identical to the status code, so branching on it is safe; type (same value as metadata.error_type) is always present, and it separates the different reasons behind the same status code, such as the two kinds of 503
3metadata.refusal_reasonWithin "refusal-class" errors, pin down exactly which kind of refusal it is (quota, budget, arrears, IP)
A failed call: find the cause in order Do not stop at the HTTP status. Read the status, then error.code and error.type, then metadata.refusal_reason. If that is still unclear, check Call Traces, the audit log, and Model Health. A failed call: find the cause in order 1. Read the HTTP status Which class of failure Auth, missing, limit, upstream 2. Read code and type code matches the status Same code: read type 3. Read refusal_reason Only on a refusal Quota, budget, arrears, IP One 403 can be key type, quota, source IP, DLP, or budget. One 503 has two causes. Split them with error.type. If the three steps are still unclear, check Call Traces, the audit log, and Model Health.
A failed call: locate the cause in a fixed order

If you finish these three steps and still aren't sure, then check Call Traces, the audit log, and Model Health (see Routing).

What to judge first by status code

StatusWhat to judge first
400Request shape, DLP, whether the provider filter emptied out the candidates
401Whether the key exists, is expired, or is disabled
402Whether the account balance is insufficient
403Key type, quota, budget, source IP, DLP
404Whether the model route exists, or whether the generation has not been written yet
429Rate limit; handle it per Retry-After
503Whether all upstream candidates are unavailable

Status code meanings and handling

Status codeMeaningHow to handle
401Key missing, malformed, or revokedCheck the header. 401 is only about the credential itself
403The credential is valid, but this call isn't allowed throughKey type doesn't match the endpoint, quota is used up, or the source IP isn't on this key's allowlist; check metadata.refusal_reason
404No route is configured for this modelChange the model name, add a route, or add a catch-all
402Account arrears (the only meaning)Top up; recovery is automatic
429Requests per minute exceededBack off per Retry-After, see Rate limits and quotas
502Tare couldn't get a usable response from the upstream provider (including problems with Tare's own credential at that provider, which aren't your concern)Retry; if it keeps happening, look into this channel
503The same status code has two different causes behind it, and the status code alone can't tell them apart — look at error.type. provider_overloaded: the route is configured, but all its channels are currently failing. provider_unavailable: Tare's billing service is currently unreachable, unrelated to the modelRetry with backoff for both; the first is a route-configuration problem, the second is unrelated to your model and routes
504The upstream didn't respond within the timeoutRetry; a consistently slow channel should have its timeout shortened or a backup route added
500A service failure on Tare's sideRetry; include the request ID when you contact support

Distinguishing the three kinds of "insufficient balance"

An exhausted quota returns 403; don't confuse it with 402. 402 only means account arrears. The division of labor between the two codes is about "whose problem this is": 402 is money the account owes the platform, while 403 is stopped by a governance threshold (key quota, monthly budget).

The table below is the only authoritative statement:

CaseHTTPerror.type / metadata.error_typemetadata.refusal_reason
This key's cumulative quota is used up403token_limit_exceededkey_credit_exhausted
The account's monthly budget is maxed out403token_limit_exceededbudget_exhausted
Account arrears402payment_requiredaccount_balance_insufficient
The call source isn't on this key's IP allowlist403permission_deniedsource_ip_not_allowed

What to say when relaying to an end user

When a platform-type customer needs to relay the cause to an end user, look at refusal_reason; don't read the copy verbatim:

refusal_reasonMeaningWhat to tell the end user
key_credit_exhaustedThis key's cumulative quota is used up"Your quota is used up"; topping up fixes it
budget_exhaustedThe account's monthly budget is maxed outNot their concern; don't steer them to top up
account_balance_insufficientAccount arrearsNot their concern; don't steer them to top up
source_ip_not_allowedThe source address isn't on this key's listNothing to do with money: retry from a machine that is on the list, or ask the key's holder to add this machine to the list

If you describe the middle two as "your quota is used up", the user will pay for something that isn't their concern; if you describe the last one as a quota problem, they'll go top up an account that isn't short of money at all.

Three kinds of not enough balance 402 means the account owes the platform, and a top-up restores it. 403 means the credential is valid but refused: quota, monthly budget, or source IP. Tell the end user from refusal_reason. Three kinds of not enough balance Balance, quota, or permission error HTTP first: 402 is arrears, 403 needs refusal_reason 402 · account arrears Only this: the account owes the platform Top up. Recovery is automatic. 403 · valid credential, still refused Quota, monthly budget, or source IP Read refusal_reason: quota, budget, IP Tell the end user from refusal_reason, not by reading the message text. key_credit_exhausted: offer a top-up. Budget and arrears are not the user's. source_ip_not_allowed is not money.
How to tell the three kinds of "insufficient balance" apart
Code / Terminal
{"error":{"code":403,"type":"token_limit_exceeded","message":"...","metadata":{
  "error_type":"token_limit_exceeded",
  "refusal_reason":"key_credit_exhausted"}}}

The two response envelopes

Different endpoints return different envelopes, so when you integrate, first recognize which kind you're hitting:

EndpointSuccessFailure
/v1/chat/completions, /v1/embeddings, /v1/images, /v1/videos/generations*, /v1/keys/*, /v1/models, /v1/generationOpenAI shapeHTTP non-2xx + {"error":{…}}
/v1/integration/*, /v1/content-settings*, /v1/alerts/*, /v1/mocks/*{"code","message","data","success"}HTTP non-2xx, and the body is still this envelope (not 200 + success:false)

When you reach the reconciliation endpoints through the api.jamerly.dev gateway, the gateway doesn't unwrap the upstream envelope, so the business data is nested two levels deep (data.data); a direct connection to tare.jamerly.ai has only one level. The test is whether a code/success is nested inside data again, regardless of deployment location. This holds under both deployments.

The shape of the error body

Code / Terminal
{"error":{
  "code": 403,
  "type": "token_limit_exceeded",
  "message": "...",
  "metadata": {
    "error_type": "token_limit_exceeded",
    "refusal_reason": "key_credit_exhausted",
    "provider_code": "503",
    "provider_raw": "{\"error\":{\"code\":\"model_not_found\",\"message\":\"...\"}}"
  }}}
FieldGuarantee
error.codeAlways equals the HTTP status code; branching on it is safe
error.typeAlways present; the OpenAI SDK reads this cell
metadata.error_typeSame value as error.type; some SDKs read only this cell
metadata.refusal_reasonPresent only for the three kinds of refusal above
metadata.provider_codeThe upstream's raw status code, forwarded as-is, may be missing
metadata.provider_rawNot guaranteed. On a BYOK channel (your own provider key) it may carry the upstream's raw response; on platform and Token Market channels it is not included

error.message is generated by Tare: it states which class of failure this is. When the failure stems from this request itself (a malformed tool schema, an out-of-range parameter), message is the upstream's one-line explanation, taken from error.message in the upstream's error body; the body's other fields are not returned.

The top-level type and metadata.error_type are the same value, deliberately duplicated: the two ecosystems don't read the same cell. If you only provide the latter, a client written against the OpenAI SDK gets undefined, without an error — it just displays a clear refusal as an "unknown error".

The values of error_type stay unchanged; the finer breakdown is added on refusal_reason.

Distinguishing 404 from 503

"No route configured" is fixed by changing the config; "all upstreams failed" is fixed by waiting. Merging them into one status code would point people in the wrong direction, which is why the catch-all route only covers the 404 side and not the 503 side.

Here we use 404 rather than 402: 402 means "you can continue after paying", whereas this error won't get better no matter how much you pay. Otherwise you'd top up first, then check the balance, and only at the end find out the model name was misspelled.

There's another easy-to-confuse pair of 404 and 503, on endpoints like embeddings (for details see the Endpoint list):

  • 503: All candidate channels are in the circuit-breaker state. It means "not right now", and the fix is to wait a bit and retry. This is recorded as an incident of type UPSTREAM_ALL_DOWN, visible on the model's health timeline.
  • 404: This model has no pricing on platform channels. It means "a configuration problem", and the fix is to switch to your own channel, or contact us to price this model. On platform channels, tokens are bought from upstream by the platform, and when the price list is missing this row the pricing computes to 0. Better to fail clearly than to serve silently for free.

Both are reported the same way as other endpoints: UPSTREAM_ALL_DOWN is a distinct incident type.

model_not_found is an upstream error code, meaning the upstream doesn't have this model. It's not the same thing as the 404 for "Tare has no route configured for this model".

Has a route but the modality doesn't match

Returns 404, but with a different message: the configured upstream doesn't accept images (or audio, or video). The fix is to tick that input in the model's Capabilities on the Routing page, or switch to a model that supports that input.

A successful call with no text

If a reasoning model returns no text, the output limit (max_tokens) was likely used up by reasoning before it started answering. Raise max_tokens.

404 and 503: same code, different cause 404 and 503 each have more than one cause. 404 is configuration: no route, a modality mismatch, or an unpriced platform channel. 503 is temporary: every channel failed, the billing service is down, or embeddings candidates are all open. 404 and 503: same code, different cause You got a 404 or a 503 The status is not enough. Read error.type and context. 404 · config. A change fixes it. No route: fix the name, add one, or catch-all Modality mismatch: declare it on the route Platform channel unpriced: use your own 503 · temporary. Wait. provider_overloaded: every channel failed provider_unavailable: billing is down embeddings all open: back off and retry Catch-all covers only a model with no route. It does not fix modality or price. For 503, find the cause and back off.
404 vs 503: same code, different cause

Next steps

  • To test one error branch over and over: read Drills (Mock).
  • To understand how the "source IP allowlist" in 403 is configured: read API Key.
  • To understand how to tune the rate-limit tier: read Rate limits and quotas.
Docs last updated Nov 27, 2026, 12:56 (UTC+8)