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.
Normalize Anthropic Messages usage shape.
(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 usage shape.
Falls back to Anthropic-style top-level cache fields when an OpenAI-compatible proxy (OpenRouter, Vercel AI Gateway, Cline) routes a Claude model and surfaces cache stats outside of prompt_tokens_details. Without this fallback cache writes count as 0 and cache reads are missed entirely — port of cline/cline#10266.
Perplexity adds :citation_tokens and :num_search_queries to the same envelope — both pass through to canonical fields when present.
Normalize OpenAI Chat Completions usage shape. Falls back to Anthropic-style top-level cache fields when an OpenAI-compatible proxy (OpenRouter, Vercel AI Gateway, Cline) routes a Claude model and surfaces cache stats outside of prompt_tokens_details. Without this fallback cache writes count as 0 and cache reads are missed entirely — port of cline/cline#10266. Perplexity adds :citation_tokens and :num_search_queries to the same envelope — both pass through to canonical fields when present.
(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 |