Skip to main content

Module provider_normalization

Module provider_normalization 

Source
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§

NormalizedUsage
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 usageMetadata object 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.