pub struct ApiCallError {
pub url: String,
pub request_body_values: Value,
pub status_code: Option<u16>,
pub provider_code: Option<String>,
pub message: String,
pub response_body: Option<String>,
pub response_headers: Option<HashMap<String, String>>,
pub data: Option<Value>,
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 verbatim when
one is available; transport and parsing failures use a library message
with the source detail appended. The HTTP status is always 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.
Every producer must provide the sanitized request URL and request values.
This keeps transport and response failures self-contained and matches the
AI SDK’s APICallError contract.
Fields§
§url: StringSanitized request URL. Required for every API-derived failure.
request_body_values: ValueSanitized request values used to create the API request.
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: StringHuman-readable failure text. Provider text is verbatim when available; locally detected transport/parse failures include their source detail. Never includes an HTTP 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.
response_headers: Option<HashMap<String, String>>Sanitized response headers.
data: Option<Value>Parsed provider error data.
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.
Implementations§
Trait Implementations§
Source§impl Clone for ApiCallError
impl Clone for ApiCallError
Source§impl Debug for ApiCallError
impl Debug for 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