Skip to content

One first-party LLM price table: llm_call_cost_usd (#81) - #84

Merged
thorwhalen merged 2 commits into
mainfrom
first-party-llm-prices
Oct 13, 2026
Merged

thorwhalen merged 2 commits into
mainfrom
first-party-llm-prices

Conversation

@thorwhalen

@thorwhalen thorwhalen commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

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 own source and date), plus get_llm_price, list_llm_prices, llm_prices_table_version, LlmPrice.

  • Rows: the union of reelee agent.ANTHROPIC_PRICES_USD_PER_MTOK (12 models, Haiku 5.5 long-prompt rates, cache ratios materialized per row), reelee chat_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).
  • Unlisted model: the provider's dearest listed rates and 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 when known is false.
  • Exact model ids only, as in reelee's relay (a dated snapshot is not its family).
  • Backward compatible: purely additive; nothing existing changes. 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's model_call_cost_usd and price_usd on 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_usd and chat_relay.price_usd can become thin wrappers over llm_call_cost_usd (keeping their import paths); foley _usage_cost / _estimate likewise. 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's int(...); (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: new cache_write_1h_usd_per_mtok column (2x input), read from usage.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.

thorwhalen and others added 2 commits October 13, 2026 15:43
…OpenAI (#81)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…mpt in the unknown bound, read-only table, honest 'not a ceiling' wording (#81)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thorwhalen
thorwhalen merged commit d6e23ff into main Oct 13, 2026
12 checks passed
@thorwhalen
thorwhalen deleted the first-party-llm-prices branch October 13, 2026 16:41
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.

One first-party LLM price table (Anthropic, OpenAI) instead of three copies in reelee and foley

1 participant