Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/_tdvutil/llmcost.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 16 additions & 0 deletions tests/test_llmcost.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down
Loading