Usage normalization across providers.
Honesty rule: cache / reasoning / citation / search counters are present in the normalized map ONLY when the provider reported them. Absent != 0. Callers (and the response-stamping layer) use absence to distinguish 'provider was silent' from 'provider explicitly said 0', which matters for :cache/status surfaced on the canonical response.
Usage normalization across providers. Honesty rule: cache / reasoning / citation / search counters are present in the normalized map ONLY when the provider reported them. Absent != 0. Callers (and the response-stamping layer) use absence to distinguish 'provider was silent' from 'provider explicitly said 0', which matters for :cache/status surfaced on the canonical response.
(normalize-anthropic-usage u)Normalize Anthropic Messages usage shape. Anthropic reports uncached, cache-read, and cache-creation input tokens as disjoint counts.
Normalize Anthropic Messages usage shape. Anthropic reports uncached, cache-read, and cache-creation input tokens as disjoint counts.
(normalize-codex-usage u)Normalize OpenAI Responses/Codex usage shape.
Normalize OpenAI Responses/Codex usage shape.
(normalize-embedding-usage u)Normalize an embedding-endpoint usage map. Embedding responses lack completion_tokens; OpenAI returns {prompt_tokens, total_tokens}, the compatible providers do the same. Caches and reasoning aren't a thing here.
Normalize an embedding-endpoint usage map. Embedding responses lack
completion_tokens; OpenAI returns {prompt_tokens, total_tokens}, the
compatible providers do the same. Caches and reasoning aren't a thing
here.(normalize-gemini-usage u)Normalize Gemini native usage shape.
Normalize Gemini native usage shape.
(normalize-openai-usage u)Normalize OpenAI Chat Completions and compatible usage shapes.
Cache counters have several official locations: OpenAI-style token details, Together's flat cached_tokens, and Anthropic-style top-level fields exposed by proxies. Locations are alternatives rather than additive counters, so each logical counter is selected once before uncached input is calculated.
OpenRouter adds cache_write_tokens to prompt_tokens_details. OpenAI image and audio responses use input/output or prompt/completion token-detail envelopes. Raw usage is retained so text/modality and provider billing details without canonical fields remain available.
Normalize OpenAI Chat Completions and compatible usage shapes. Cache counters have several official locations: OpenAI-style token details, Together's flat cached_tokens, and Anthropic-style top-level fields exposed by proxies. Locations are alternatives rather than additive counters, so each logical counter is selected once before uncached input is calculated. OpenRouter adds cache_write_tokens to prompt_tokens_details. OpenAI image and audio responses use input/output or prompt/completion token-detail envelopes. Raw usage is retained so text/modality and provider billing details without canonical fields remain available.
(normalize-usage provider raw-usage)Dispatch to the correct normalizer based on provider keyword.
Dispatch to the correct normalizer based on provider keyword.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |