Liking cljdoc? Tell your friends :D

llm.sdk.usage

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.
raw docstring

->intclj

(->int x)
source

normalize-anthropic-usageclj

(normalize-anthropic-usage u)

Normalize Anthropic Messages usage shape.

Normalize Anthropic Messages usage shape.
sourceraw docstring

normalize-codex-usageclj

(normalize-codex-usage u)

Normalize OpenAI Responses/Codex usage shape.

Normalize OpenAI Responses/Codex usage shape.
sourceraw docstring

normalize-embedding-usageclj

(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.
sourceraw docstring

normalize-gemini-usageclj

(normalize-gemini-usage u)

Normalize Gemini native usage shape.

Normalize Gemini native usage shape.
sourceraw docstring

normalize-openai-usageclj

(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.
sourceraw docstring

normalize-usageclj

(normalize-usage provider raw-usage)

Dispatch to the correct normalizer based on provider keyword.

Dispatch to the correct normalizer based on provider keyword.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close