From 80d44851b9c9dc67578ee7656e13fe75eb6fe615 Mon Sep 17 00:00:00 2001 From: ViditOstwal Date: Thu, 6 Aug 2026 20:30:43 +0530 Subject: [PATCH] Document Anthropic cache token accounting in LLM provider docs. Explain how split Anthropic input counters map to UsageMetrics and link to the flows field semantics section. Co-authored-by: Cursor --- docs/edge/en/concepts/llms.mdx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/edge/en/concepts/llms.mdx b/docs/edge/en/concepts/llms.mdx index 3c4470644..c928aa755 100644 --- a/docs/edge/en/concepts/llms.mdx +++ b/docs/edge/en/concepts/llms.mdx @@ -418,6 +418,27 @@ In this section, you'll find detailed examples that help you select, configure, - Token usage tracking - Multi-turn tool use conversations + **Token usage and prompt caching:** + + Anthropic reports billed input in separate counters — `input_tokens` (uncached), + `cache_read_input_tokens`, and `cache_creation_input_tokens`. CrewAI folds all + three into `prompt_tokens` (and native `input_tokens` in provider responses) so + `total_tokens` reflects full billed usage on cached workloads. + + `cached_prompt_tokens` records the cache-read portion as a breakdown only; it is + already included in `prompt_tokens` and must not be added again to + `total_tokens`. + + ```python Code + usage = llm.get_token_usage_summary() + # total_tokens == prompt_tokens + completion_tokens + # prompt_tokens includes cache read + cache write for Anthropic + ``` + + See [UsageMetrics field semantics](/concepts/flows#usagemetrics-field-semantics) + for the provider-neutral contract used by `crew.usage_metrics` and + `flow.usage_metrics`. + **Important Notes:** - `max_tokens` is a **required** parameter for all Anthropic models - Claude uses `stop_sequences` instead of `stop`