Skip to content

bug: normalize prompt_tokens across Anthropic providers#1565

Open
BillionClaw wants to merge 1 commit intoPortkey-AI:mainfrom
BillionClaw:clawoss/fix/prompt-tokens-normalization-1564
Open

bug: normalize prompt_tokens across Anthropic providers#1565
BillionClaw wants to merge 1 commit intoPortkey-AI:mainfrom
BillionClaw:clawoss/fix/prompt-tokens-normalization-1564

Conversation

@BillionClaw
Copy link
Copy Markdown

Description:

  • Fixed inconsistent prompt_tokens normalization between Anthropic direct API, Vertex AI, and Bedrock providers
  • All three providers now include cache tokens in prompt_tokens, matching the OpenAI convention where prompt_tokens_details.cached_tokens provides the breakdown

Changes:

  • Anthropic direct API: prompt_tokens now includes input_tokens + cache_creation_input_tokens + cache_read_input_tokens
  • Vertex AI: prompt_tokens now includes input_tokens + cache_creation_input_tokens + cache_read_input_tokens
  • Bedrock: already correct (no changes needed)

Tests:

  • Added unit tests verifying consistent token counting across all three providers
  • Tests confirm prompt_tokens includes cache tokens while prompt_tokens_details.cached_tokens provides the breakdown

Fixes #1564

Ensure consistent prompt_tokens normalization across all Anthropic
providers (direct API, Vertex AI, and Bedrock).

Previously:
- Anthropic direct API and Vertex AI: prompt_tokens only included input_tokens
- Bedrock: prompt_tokens included input + cache tokens

Now all providers include cache tokens in prompt_tokens, with the
cache breakdown available in prompt_tokens_details.cached_tokens.

Fixes Portkey-AI#1564
@BillionClaw BillionClaw force-pushed the clawoss/fix/prompt-tokens-normalization-1564 branch from f54f0eb to 2336364 Compare March 17, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Inconsistent prompt_tokens normalization across Anthropic providers (direct API vs Vertex AI vs Bedrock)

1 participant