Bug Description
Claude models (opus-4-6, sonnet-4-6, sonnet-4-5, etc.) are being charged at ~2x the correct rate when the request's total input context exceeds 200K tokens. This affects all token types: input, output, cache_read, and cache_creation.
Root Cause
The TOML price table (prices-base.toml) contains nested [models."claude-xxx".pricing.anthropic] sections that include input_cost_per_token_above_200k_tokens and similar fields with doubled rates (e.g., input: $10/MTok vs standard $5/MTok for opus-4-6).
The pricing resolution chain in pricing-resolution.ts uses mergePriceData() which spreads the nested provider pricing onto the base price data:
// mergePriceData: {...base, ...pricingNode}
// This adds above_200k fields from pricing.anthropic to the resolved price data
Then in cost-calculation.ts, the cost calculation hits this priority chain:
if (longContextPricing && ...) { // P1: explicit long_context_pricing (usually null)
} else if (inputAboveThreshold != null) { // P2: above_200k fields ← BUG HERE
} else if (context1mApplied) { // P3: hardcoded 2x/1.5x fallback
} else { // P4: standard rate
}
Since modern Claude models (opus-4-6, sonnet-4-6) have flat pricing regardless of context length, the above_200k fields should not exist. But because they're present in the nested TOML pricing sections, they get merged into the resolved price data and trigger the P2 path.
Impact
- Affected models: claude-opus-4-6, claude-sonnet-4-6, claude-sonnet-4-5, claude-sonnet-4-5-20250929, and all regional variants
- Affected requests: Any request where
input_tokens + cache_creation_input_tokens + cache_read_input_tokens > 200,000
- Overcharge rate: ~96-100% (nearly 2x the correct cost)
- Additional issue: Even if above_200k fields are removed, the
context_1m_applied fallback path (P3) still applies hardcoded 2x input / 1.5x output multipliers for Codex provider type, causing ~5-50% overcharge
Example (claude-opus-4-6)
| Token Type |
Standard Rate |
above_200k Rate (from TOML) |
Overcharge |
| input |
$5/MTok |
$10/MTok |
2x |
| output |
$25/MTok |
$37.5/MTok |
1.5x |
| cache_read |
$0.5/MTok |
$1/MTok |
2x |
| cache_creation_5m |
$6.25/MTok |
$12.5/MTok |
2x |
TOML Source
The problematic fields are in nested pricing sections like:
[models."claude-opus-4-6".pricing."anthropic"]
input_cost_per_token = 0.000005
output_cost_per_token = 0.000025
input_cost_per_token_above_200k_tokens = 0.00001 # ← should be removed
output_cost_per_token_above_200k_tokens = 0.0000375 # ← should be removed
cache_read_input_token_cost_above_200k_tokens = 0.000001
cache_creation_input_token_cost_above_200k_tokens = 0.0000125
Suggested Fix
Option A: Remove above_200k from TOML (data fix)
Remove *_above_200k_tokens fields from all pricing.anthropic / pricing.opencode / pricing.vertex_ai sections for Claude models that have flat pricing.
Option B: Code-level guard (defensive fix)
In cost-calculation.ts, skip the above_200k pricing path when the above_200k rate equals the standard rate, or add a model family check.
Option C: Use long_context_pricing with multiplier 1.0
Add explicit long_context_pricing config with multiplier 1.0 for flat-pricing models, so the P1 path is hit with no surcharge.
Workaround
Create source='manual' price records with above_200k fields set equal to standard rates. Manual records have highest priority in findLatestPriceByModel and won't be overwritten by TOML sync.
Bug Description
Claude models (opus-4-6, sonnet-4-6, sonnet-4-5, etc.) are being charged at ~2x the correct rate when the request's total input context exceeds 200K tokens. This affects all token types: input, output, cache_read, and cache_creation.
Root Cause
The TOML price table (
prices-base.toml) contains nested[models."claude-xxx".pricing.anthropic]sections that includeinput_cost_per_token_above_200k_tokensand similar fields with doubled rates (e.g., input: $10/MTok vs standard $5/MTok for opus-4-6).The pricing resolution chain in
pricing-resolution.tsusesmergePriceData()which spreads the nested provider pricing onto the base price data:Then in
cost-calculation.ts, the cost calculation hits this priority chain:Since modern Claude models (opus-4-6, sonnet-4-6) have flat pricing regardless of context length, the
above_200kfields should not exist. But because they're present in the nested TOML pricing sections, they get merged into the resolved price data and trigger the P2 path.Impact
input_tokens + cache_creation_input_tokens + cache_read_input_tokens > 200,000context_1m_appliedfallback path (P3) still applies hardcoded 2x input / 1.5x output multipliers for Codex provider type, causing ~5-50% overchargeExample (claude-opus-4-6)
TOML Source
The problematic fields are in nested pricing sections like:
Suggested Fix
Option A: Remove above_200k from TOML (data fix)
Remove
*_above_200k_tokensfields from allpricing.anthropic/pricing.opencode/pricing.vertex_aisections for Claude models that have flat pricing.Option B: Code-level guard (defensive fix)
In
cost-calculation.ts, skip the above_200k pricing path when the above_200k rate equals the standard rate, or add a model family check.Option C: Use
long_context_pricingwith multiplier 1.0Add explicit
long_context_pricingconfig with multiplier 1.0 for flat-pricing models, so the P1 path is hit with no surcharge.Workaround
Create
source='manual'price records withabove_200kfields set equal to standard rates. Manual records have highest priority infindLatestPriceByModeland won't be overwritten by TOML sync.