Repository navigation
One first-party LLM price table: llm_call_cost_usd (#81) - #84
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #81.
Adds
falaw.llm_call_cost_usd(provider, model, usage, *, prices=None) -> (usd, known), one first-party price table for Anthropic and OpenAI (falaw/data/first_party_llm_prices.json, every row with its ownsourceanddate), plusget_llm_price,list_llm_prices,llm_prices_table_version,LlmPrice.agent.ANTHROPIC_PRICES_USD_PER_MTOK(12 models, Haiku 5.5 long-prompt rates, cache ratios materialized per row), reeleechat_relay.OPENAI_PRICES_USD_PER_MTOK(8 models), and foley's Anthropic subset (contained in reelee's). Dates carried over: Anthropic 2026-10-06, OpenAI 2026-09-28. I did not re-verify the numbers against the vendors; they are the copies' numbers.usage: a dict or SDK object; Anthropic's four token fields; OpenAI's Responses and Chat Completions shapes (cached tokens at the cached rate, input includes cached).known=False. This is not a ceiling (an older, pricier model can cost more), so a caller that must never under-count, like reelee's chat relay, which refuses an unpriced model, has to refuse whenknownis false.llm_rates(fal-routed LLMs) is untouched.Verification: new tests (
tests/test_llm_prices.py), doctests, full suite 696 passed. A one-off cross-check against reelee'smodel_call_cost_usdandprice_usdon 3,000 random usages (all models plus unknown ones, all cache fields, both sides of the 100K Haiku threshold) gave 0 mismatches.reelee / foley need: a falaw release, then a falaw bump. reelee
agent.model_call_cost_usdandchat_relay.price_usdcan become thin wrappers overllm_call_cost_usd(keeping their import paths); foley_usage_cost/_estimatelikewise. I did not touch either repo.Adversarial review (fresh Opus subagent): problems found, all confirmed and fixed here. (1) token counts that were floats, numeric strings or numpy ints priced at $0 with
known=True: now parsed like reelee'sint(...); (2) the unknown-model "upper bound" was only the dearest listed rate, so wording corrected (and the migration note above); (3) 1-hour cache writes were charged at the 5-minute rate: newcache_write_1h_usd_per_mtokcolumn (2x input), read fromusage.cache_creation.ephemeral_1h_input_tokens; (4) with a caller-supplied table the unknown-model bound ignored long-prompt rates: now included. Also: cached tokens beyond input are no longer capped (matches reelee, the higher number), non-string model ids no longer crash, the loaded table is read-only. Re-ran the 3,000-case cross-check against reelee after the fixes: 0 mismatches.