Skip to content
Open
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
8 changes: 7 additions & 1 deletion amplifier_module_provider_anthropic/_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,14 @@
},
# ------------------------------------------------------------------
# Claude Haiku 3.5 ($0.80 / $4.00 / $0.08 / $1.00)
#
# The served id is claude-3-5-haiku-20241022: Claude 3-generation ids put
# the version before the family, and later ids put the family first.
# "claude-haiku-3-5-20250929" was neither shape -- family-first ordering
# with Sonnet 4.5's snapshot date. `compute_cost` does an exact
# `_RATES.get()`, so the real id missed and Haiku 3.5 cost returned None.
# ------------------------------------------------------------------
"claude-haiku-3-5-20250929": {
"claude-3-5-haiku-20241022": {
"input_per_m": Decimal("0.80"),
"output_per_m": Decimal("4.00"),
"cache_read_per_m": Decimal("0.08"),
Expand Down
27 changes: 27 additions & 0 deletions tests/test_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,33 @@ def test_unknown_model_returns_none():
assert result is None, f"Expected None for unknown model, got {result!r}"


# ---------------------------------------------------------------------------
# Haiku 3.5 is keyed by its served model id
# ---------------------------------------------------------------------------
def test_haiku_35_real_model_id_is_priced():
"""The id the API actually returns must resolve to the Haiku 3.5 rates."""
result = compute_cost("claude-3-5-haiku-20241022", input_tokens=1_000_000)
assert result == Decimal("0.80")


def test_haiku_35_output_and_cache_rates():
assert compute_cost(
"claude-3-5-haiku-20241022", output_tokens=1_000_000
) == Decimal("4.00")
assert compute_cost(
"claude-3-5-haiku-20241022", cache_read_input_tokens=1_000_000
) == Decimal("0.08")
assert compute_cost(
"claude-3-5-haiku-20241022", cache_creation_input_tokens=1_000_000
) == Decimal("1.00")


def test_former_haiku_35_key_was_never_a_served_model_id():
"""No model was served as claude-haiku-3-5-20250929, so it must not price."""
result = compute_cost("claude-haiku-3-5-20250929", input_tokens=1_000_000)
assert result is None


# ---------------------------------------------------------------------------
# (g) None != Decimal('0'): unknown is distinct from free
# ---------------------------------------------------------------------------
Expand Down