pub struct ApiCallError {
pub status_code: Option<u16>,
pub provider_code: Option<String>,
pub message: String,
pub response_body: Option<String>,
pub request_id: Option<String>,
pub retry_after_ms: Option<u64>,
pub is_retryable: bool,
}Expand description
What a failed API call observed — the field set of the AI SDK’s
APICallError (statusCode / responseBody), which this project’s error
taxonomy mirrors (docs/internal/vercel-research/07-kernel-infrastructure.md).
Carried by AiMuxError::ApiCall alone. There are no per-status
variants: a 401, 404 or 429 is an ApiCall error whose classification is
read from status_code, exactly as the AI SDK reads
APICallError.statusCode. Transport failures (connection reset, DNS,
body read) are ApiCall errors too — no response arrived, so
status_code is None and is_retryable is true, exactly as the AI
SDK’s handleFetchError builds an APICallError with no statusCode
and isRetryable: true. message holds the provider’s text only —
the status is a field, never baked into the string; Display composes
the human-readable form from the fields at print time, so nothing
downstream has to parse it back out.
APICallError fields not carried in this round: url /
requestBodyValues / responseHeaders (the request context is not
available at the error-construction sites today; all fields are
#[serde(default)], so adding them later is not a breaking change).
Fields§
§status_code: Option<u16>HTTP status of the response, when it came from one
(APICallError.statusCode). Always the observed status: the HTTP
layer fills it for every response-derived error; errors built without
an HTTP exchange leave it None.
provider_code: Option<String>Provider’s machine-readable code (OpenAI’s code/type,
e.g. "rate_limit_exceeded" vs "insufficient_quota"). Never an HTTP
status. Our normalized take on APICallError.data.
message: StringThe provider’s message, verbatim. No status prefix.
response_body: Option<String>The raw response body, verbatim (APICallError.responseBody) — the
lossless evidence when message/provider_code are extractions.
None when the error did not come from a response body.
request_id: Option<String>Provider-assigned request id, from the x-request-id / request-id
response header when one was sent. Filled by the shared HTTP layer.
retry_after_ms: Option<u64>Retry hint in milliseconds, distilled from the retry-after-ms /
retry-after response headers on a 429. The classification lives in
status_code; this is the matching action input.
is_retryable: boolWhether retrying can help (APICallError.isRetryable) — stored at
construction, exactly like the AI SDK: the response path computes it
from the status (408/409/429 or 5xx), and the transport path (no response, so
no status to compute from) sets it to true explicitly.
Trait Implementations§
Source§impl Clone for ApiCallError
impl Clone for ApiCallError
Source§fn clone(&self) -> ApiCallError
fn clone(&self) -> ApiCallError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ApiCallError
impl Debug for ApiCallError
Source§impl Default for ApiCallError
impl Default for ApiCallError
Source§fn default() -> ApiCallError
fn default() -> ApiCallError
Source§impl<'de> Deserialize<'de> for ApiCallError
impl<'de> Deserialize<'de> for ApiCallError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ApiCallError
impl Display for ApiCallError
Source§impl Serialize for ApiCallError
impl Serialize for ApiCallError
Source§impl TS for ApiCallError
impl TS for ApiCallError
Source§type WithoutGenerics = ApiCallError
type WithoutGenerics = ApiCallError
WithoutGenerics should just be Self.
If the type does have generic parameters, then all generic parameters must be replaced with
a dummy type, e.g ts_rs::Dummy or (). The only requirement for these dummy types is that
EXPORT_TO must be None. Read moreSource§type OptionInnerType = ApiCallError
type OptionInnerType = ApiCallError
std::option::Option<T>, then this associated type is set to T.
All other implementations of TS should set this type to Self instead.Source§fn docs() -> Option<String>
fn docs() -> Option<String>
TS is derived, docs are
automatically read from your doc comments or #[doc = ".."] attributesSource§fn decl_concrete(cfg: &Config) -> String
fn decl_concrete(cfg: &Config) -> String
TS::decl().
If this type is not generic, then this function is equivalent to TS::decl().Source§fn decl(cfg: &Config) -> String
fn decl(cfg: &Config) -> String
type User = { user_id: number, ... }.
This function will panic if the type has no declaration. Read moreSource§fn inline(cfg: &Config) -> String
fn inline(cfg: &Config) -> String
{ user_id: number }.
This function will panic if the type cannot be inlined.Source§fn inline_flattened(cfg: &Config) -> String
fn inline_flattened(cfg: &Config) -> String
Source§fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn output_path() -> Option<PathBuf>
fn output_path() -> Option<PathBuf>
T should be exported, relative to the output directory.
The returned path does not include any base directory. Read moreSource§fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn dependencies(cfg: &Config) -> Vec<Dependency>where
Self: 'static,
fn dependencies(cfg: &Config) -> Vec<Dependency>where
Self: 'static,
Source§fn export(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
fn export(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
TS::export_all. Read moreSource§fn export_all(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
fn export_all(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
TS::export. Read more