Expand description
Provider-specific usage normalization for execution receipts.
Provider APIs do not agree on field names, and a response can be a stream of
partial usage observations rather than one JSON object. This module keeps
the provider differences at the boundary and deliberately represents absent
observations as None. The receipt builder can then decide how to project
those observations onto the existing wire contract.
Structs§
- Normalized
Usage - Provider-neutral usage for one logical model invocation.
Functions§
- decimal_
to_ micros - Converts a decimal string in USD into integer micros.
- decimal_
value_ to_ micros - Converts a JSON decimal USD value into micros without using floating point.
- normalize_
anthropic - Normalizes an Anthropic message, message stream event, or non-streaming body.
- normalize_
gemini - Normalizes a Gemini
usageMetadataobject or stream chunk. - normalize_
json_ lines - Alias with an explicit name for callers that already have JSON lines.
- normalize_
openai - Normalizes an OpenAI Chat Completions, Responses, or OpenRouter object.
- normalize_
provider - Normalizes a provider response while retaining the provider-specific model.
- normalize_
stream - Normalizes newline-delimited streaming events.
- try_
normalize_ provider - Returns a normalized response only when a usage fact was observed.