From b1bc70466d1dd6f463fc4c471c44833f5aee3b5f Mon Sep 17 00:00:00 2001 From: TDV Alinsa Date: Sun, 11 Oct 2026 19:54:32 -0700 Subject: [PATCH] feat(llmcost): add Claude Haiku 5.5 pricing Add Anthropic and Copilot pricing, 100k long-context tiers, current aliases, and regression coverage. --- src/_tdvutil/llmcost.py | 14 ++++++++++++-- tests/test_llmcost.py | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/_tdvutil/llmcost.py b/src/_tdvutil/llmcost.py index a46275e..34b6ed0 100644 --- a/src/_tdvutil/llmcost.py +++ b/src/_tdvutil/llmcost.py @@ -180,6 +180,13 @@ "claude-haiku-4.5": {"provider": "anthropic", "input": 1.00, "output": 5.00, "cached_input": 0.10, "cache_write": 1.25, "batch_input": 0.50, "batch_output": 2.50}, + "claude-haiku-5.5": {"provider": "anthropic", "input": 0.10, "output": 0.50, + "cached_input": 0.01, "cache_write": 0.125, + "batch_input": 0.05, "batch_output": 0.25, + "long_input": 0.50, "long_cached_input": 0.05, + "long_cache_write": 0.625, "long_output": 2.50, + "longctx_threshold": 100_000, + "notes": "Long-context >100k input tokens"}, "claude-sonnet-4.6": {"provider": "anthropic", "input": 3.00, "output": 15.00, "cached_input": 0.30, "cache_write": 3.75, "batch_input": 1.50, "batch_output": 7.50}, @@ -337,6 +344,9 @@ "long_input": 20.00, "long_cached_input": 2.00, "long_cache_write": 25.00, "long_output": 75.00, "longctx_threshold": 272_000, "notes": "Long-ctx >272k tokens"}, "copilot/claude-haiku-4.5": {"provider": "copilot", "input": 1.00, "cached_input": 0.10, "cache_write": 1.25, "output": 5.00}, + "copilot/claude-haiku-5.5": {"provider": "copilot", "input": 0.10, "cached_input": 0.01, "cache_write": 0.125, "output": 0.50, + "long_input": 0.50, "long_cached_input": 0.05, "long_cache_write": 0.625, "long_output": 2.50, "longctx_threshold": 100_000, + "notes": "Long-context >100k input tokens"}, "copilot/claude-sonnet-4": {"provider": "copilot", "input": 3.00, "cached_input": 0.30, "cache_write": 3.75, "output": 15.00}, "copilot/claude-sonnet-4.5": {'provider': 'copilot', 'input': 3.0, 'output': 15.0, 'cached_input': 0.3, 'cache_write': 3.75, 'deprecated': True, 'notes': 'No longer listed in current Copilot pricing tables'}, "copilot/claude-sonnet-4.6": {"provider": "copilot", "input": 3.00, "cached_input": 0.30, "cache_write": 3.75, "output": 15.00}, @@ -430,7 +440,7 @@ "fable5": "claude-fable-5.1", "claude-opus": "claude-opus-5.5", "claude-sonnet": "claude-sonnet-5-5", - "claude-haiku": "claude-haiku-4.5", + "claude-haiku": "claude-haiku-5.5", "claude-3.5-sonnet": "claude-sonnet-4.5", "claude-3.7-sonnet": "claude-sonnet-4.6", "claude-opus-4": "claude-opus-4.8", @@ -473,7 +483,7 @@ # Copilot shorthands "copilot-sonnet": "copilot/claude-sonnet-5", "copilot-opus": "copilot/claude-opus-5.5", - "copilot-haiku": "copilot/claude-haiku-4.5", + "copilot-haiku": "copilot/claude-haiku-5.5", "copilot-gpt5": "copilot/gpt-5.4", "copilot-gpt6": "copilot/gpt-6-astra", "raptor-mini": "copilot/raptor-mini", diff --git a/tests/test_llmcost.py b/tests/test_llmcost.py index 91cbfa6..a1c489a 100644 --- a/tests/test_llmcost.py +++ b/tests/test_llmcost.py @@ -84,6 +84,8 @@ def test_updated_gpt_5_6_prices( ("claude-fable-5.1", 10.00, 0.25, 50.00), ("claude-opus-5.5", 4.00, 0.20, 20.00), ("claude-sonnet-5-5", 2.00, 0.20, 10.00), + ("claude-haiku-5.5", 0.10, 0.01, 0.50), + ("copilot/claude-haiku-5.5", 0.10, 0.01, 0.50), ("gpt-6.1-sol", 2.00, 0.10, 10.00), ("gpt-6-luna", 0.10, 0.01, 0.50), ("copilot/gpt-6.1-sol", 2.00, 0.10, 10.00), @@ -264,6 +266,20 @@ def test_long_context_is_selected_automatically(self) -> None: assert cost.cache_write_rate == 5.00 assert cost.output_rate == 18.00 + def test_haiku_5_5_long_context_pricing(self) -> None: + m = get_model("claude-haiku-5.5") + cost = m.cost( + input_tokens=100_001, + output_tokens=1_000_000, + cache_hit_tokens=1_000_000, + cache_write_tokens=1_000_000, + ) + assert cost.pricing_tier == "long_context" + assert cost.input_rate == pytest.approx(0.50) + assert cost.cache_hit_rate == pytest.approx(0.05) + assert cost.cache_write_rate == pytest.approx(0.625) + assert cost.output_rate == pytest.approx(2.50) + def test_standard_context_can_be_forced(self) -> None: m = get_model("gpt-5.6-terra") cost = m.cost(input_tokens=272_001, output_tokens=1, long_context=False)