Skip to content

fix(cost): key Haiku 3.5 by its served model id - #107

Open
Joi Ito (Joi) wants to merge 1 commit into
microsoft:mainfrom
Joi:fix/haiku-3-5-rates-key-v2
Open

fix(cost): key Haiku 3.5 by its served model id#107
Joi Ito (Joi) wants to merge 1 commit into
microsoft:mainfrom
Joi:fix/haiku-3-5-rates-key-v2

Conversation

@Joi

Copy link
Copy Markdown

_RATES keys Haiku 3.5 under claude-haiku-3-5-20250929. That is not a model id the API serves — the word order is inverted (real ids in that generation are family-first, claude-3-5-haiku-...) and the date is Sonnet 4.5's.

compute_cost does an exact _RATES.get(), so the real id misses:

>>> compute_cost("claude-3-5-haiku-20241022", input_tokens=1_000_000)
None
>>> compute_cost("claude-haiku-3-5-20250929", input_tokens=1_000_000)
Decimal('0.80')

None is the unknown-model signal, so anywhere cost_usd is stamped from compute_cost, Haiku 3.5 spend is silently untracked rather than wrong — no error, no warning, just a gap in the cost data.

The change: rename the key to claude-3-5-haiku-20241022. Rates are untouched ($0.80 / $4.00 / $0.08 / $1.00).

The old string is not kept as an alias. No model was ever served under it, so nothing upstream or downstream can be reporting it. I checked the rest of the tree: claude-haiku-3-5-20250929 appears in several test files, but only as a _get_capabilities fixture, which does not consult _RATES — those tests are unaffected. (They are pinning capability behavior against a model id that does not exist either, which is a separate thing and left alone here.)

Tests: three cases in tests/test_cost.py — the real id prices at all four rates, and the former key returns None.

Full suite: 743 passed, 7 skipped.

`_RATES` keyed Haiku 3.5 as "claude-haiku-3-5-20250929". No model was
ever served under that string: Claude 3-generation ids put the version
before the family (claude-3-5-haiku-...), and the date belongs to Sonnet
4.5. `compute_cost` does an exact `_RATES.get()`, so the served id
missed:

    >>> compute_cost("claude-3-5-haiku-20241022", input_tokens=1_000_000)
    None
    >>> compute_cost("claude-haiku-3-5-20250929", input_tokens=1_000_000)
    Decimal('0.80')

None is the unknown-model signal, so Haiku 3.5 spend was silently
untracked rather than misreported.

Rates are unchanged ($0.80 / $4.00 / $0.08 / $1.00); only the key moves.
The old string is not kept as an alias -- nothing can be reporting a
model id that was never served.
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.

1 participant