JSON ser/de surface — to_vec / from_slice / to_string / from_str.
With the sonic feature these route to SIMD-accelerated sonic-rs;
without it, to serde_json.
Anthropic wire-format usage. Field semantics follow Anthropic convention:
input_tokens is only the uncached new portion; the three input fields
are additive components of the total prompt. Convert to canonical Usage
for any internal billing or metering use.
Gemini wire-format usage. Field semantics follow Google’s convention:
prompt_token_count is the total prompt size (includes cached portion);
cached_content_token_count is the cached subset. Convert to canonical
Usage for any internal billing or metering use.
A buffered multipart form field. Carries name, filename, content type, and
bytes across the provider trait boundary without depending on any HTTP
client crate.
OpenAI wire-format usage. Field semantics follow OpenAI/DeepSeek-openai
convention: prompt_tokens is the total prompt including cache,
prompt_cache_hit_tokens is a subset. Convert to canonical Usage for
any internal billing or metering use.
Per-model token pricing. One rate per usage axis. Secondary rates are
Option<f64> so “absent” means fall back to the coarser bucket rather
than free — see crate::ModelInfo::cost for the fallback chain.
Which provider implementation to use. Known variants map to named
dispatch paths. A self-defined name deserializes to Custom, which
dispatches as OpenAI-compatible and requires base_url at validation.
Operations on a wire-level message list. Lives as a trait so call sites
read as messages.coalesce_tool_results() rather than as free functions
taking &mut Vec<AnthropicMessage>.
A boxed, Send, dynamically-typed stream — used by Provider so the
trait can return a uniform stream type without each implementor leaking
its concrete combinator chain through an associated type.