Errors
Failures fall into three categories, and they behave differently.
Three categories
| Category | Result |
|---|---|
| Engine failure | The request is forwarded without a ceiling |
| Provider error | The provider's status, body and headers are forwarded unchanged |
| Gateway error | The gateway returns its own 400, 401 or 502 and makes no provider call, or reports that the call failed |
The Sufficiency Engine fails
Timeout, exception, or a decision that does not validate.
The request is forwarded with no ceiling and no length hint. The failure is
reported on the response and in the meted dev log as engine:<kind>:
x-meted-engine-failure timeout
x-meted-applied false
The engine runs before the upstream call and is held to engine.timeoutMs,
default 250ms.
| Kind | |
|---|---|
timeout | Exceeded the configured budget |
threw | Raised an exception |
invalid_decision | Returned something that is not a valid decision |
load_failed | Could not be loaded at start-up. The baseline engine takes over |
The provider returns an error
The provider's status code, body and headers are forwarded unchanged, with
Meted's x-meted-* headers added.
The status is classified as rate_limit (429), auth (401, 403),
invalid_request (400, 404, 422), provider_error (5xx) or http_error, and
reported on the onRecord summary as errorKind.
The provider is unreachable
{
"error": {
"message": "Upstream provider request failed: fetch failed",
"type": "api_connection_error",
"param": null,
"code": null
}
}
A gateway-generated 502 in the OpenAI error shape, when the upstream fetch
throws. Reported as upstream_unreachable.
No credential
{
"error": {
"message": "No provider credential. Set OPENAI_API_KEY in the environment where Meted runs.",
"type": "authentication_error"
}
}
A gateway-generated 401, naming the variable to set. It is returned before the
provider is called. meted dev also warns at start-up when the variable is
unset.
A malformed body
A request body that does not parse as JSON receives a gateway-generated 400
and no provider call is made.
A body that is valid JSON but has no model field cannot be sized. It is
proxied to the provider unchanged, and the provider's own response is returned.
Timeouts
Non-streaming requests are subject to gateway.requestTimeoutMs (default 120s).
Streaming requests are exempt once the stream has started.
What Meted never does
- Retry your request. Retries belong to your application.
- Modify a response body.
- Fabricate a decision when the engine fails.
- Replace a provider error with its own.