Price current Claude and OpenAI models, and future releases by family

Merged
VL
1mo ago
+223-18

Problem

The cost table in LlmUsage::PRICING had fallen behind both providers:

  • Claude: only 4.x was listed. Every request on a newer model (claude-opus-5-5, claude-sonnet-5-5, …) was saved with estimated_cost: nil. The LLM usage screen shows those rows as N/A and leaves them out of Total Cost / Avg Cost ("Based on 11 of 40 requests with cost data" on an Opus 5.5 chat).
  • OpenAI: GPT-6 Astra, GPT-6.1 Terra and GPT-6 Luna were missing (N/A). Longest-prefix matching also priced unlisted versions at an older row's rate: gpt-5.7-sol took gpt-5 ($1.25 / $10), and o1-pro took o1 ($15 instead of $150 input).

Resulting behavior

Claude (pricing page, verified November 1, 2026)

  • Adds Fable 5/5.1, Opus 4/4.1/4.5/4.6/4.7/4.8/5/5.5, Sonnet 4/4.5/4.6/5/5.5, Haiku 4.5/5.5.
  • Family rows (claude-opus, claude-sonnet, claude-haiku, claude-fable): an unlisted release (claude-opus-6, claude-opus-5-6) is estimated at its family's newest rate. Claude IDs match the exact version row (snapshot dates and suffixes ignored), otherwise the family row. Anthropic's Models API exposes no prices, so a bundled fallback is the only offline option.
  • Cache reads use Anthropic's per-model rate: 0.1x input by default, 0.05x for Opus 5.5 and Sonnet 5.5, 0.025x for Fable 5.1.
  • Haiku 5.5's long-context tier ($0.50 / $2.50 above 100K) counts cache reads and writes in the prompt length, as Anthropic bills it.
  • OpenRouter's dotted IDs (anthropic/claude-opus-4.6) match their own row. When an OpenAI-compatible endpoint gives no usable usage.cost, cached Claude input (prompt_tokens_details.cached_tokens) is priced at the cache-read rate (Provider::Openai::UsageCost).

OpenAI (pricing page and model pages, verified November 1, 2026)

  • Adds GPT-6 Astra, GPT-6.1 Terra and GPT-6 Luna, each with its 272K long-context rate. Also adds o1-pro, gpt-4o-2024-05-13, gpt-5.3-codex and chat-latest.
  • A row covers its dated snapshots (gpt-4.1-2025-04-14) but not later versions. The part of the ID after the prefix may not continue the version number.
  • Tier rows (gpt-astra, gpt-sol, gpt-terra, gpt-luna): an unlisted release of a tier (gpt-6.2-sol, gpt-7-astra) is estimated at the tier's newest rate. Other unlisted versions (gpt-5.9) now show N/A instead of an older model's rate.
  • Adds the gpt-5.6 alias (routes to GPT-5.6 Sol) and the trusted-access gpt-5.6-cyber / gpt-5.5-cyber rows ($12.50 / $75). Without those rows they would match gpt-5.6 or gpt-5.5. Rosalind models are not added.

docs/hosting/ai.md cost section updated. PRICING_VERIFIED_ON stays October 17, because the Gemini rows were not re-checked.

Saved usage costs are not recalculated (unchanged behavior). Not modeled (unchanged): OpenAI cached-input discounts, Anthropic 1-hour cache writes, fast/priority modes, regional uplifts, Batch/Flex.

Validation

  • bin/rails test test/models/llm_usage_test.rb test/models/provider test/models/rule/action_executor/auto_categorize_test.rb test/controllers/settings/llm_usages_controller_test.rb test/models/assistant_test.rb test/lib/langfuse_tracing_test.rb: 1148 runs, 0 failures.
  • Full local suite on the first commit: models 9018 runs and rest 1107 runs, both green. Controllers: 3805 runs with the same 2 failures + 1 error that fail on main at 5ed910330 (pages_controller_test.rb:905, reports_controller_test.rb:113, bills_controller_test.rb:431).
  • CI test_system fails only on test/system/reports_test.rb:74, which also fails on main (run 41261368820).
  • bin/rubocop: no offenses. Biome: clean. Brakeman: 0 warnings. No UI, ERB, or JS changes.

Summary by CodeRabbit

  • Updates
    • Updated Claude pricing estimates with additional model rates, cache-creation and cache-read pricing, and family-based estimates for unlisted versions.
    • Haiku 5.5 estimates now use higher rates above 100,000 prompt tokens, including when cached tokens affect the long-context tier.
    • Added pricing estimates and tier fallbacks for newer GPT models, with improved handling of model versions and dated snapshots. Other unlisted OpenAI models no longer inherit older model rates.
  • Documentation
    • Expanded the AI hosting guide’s model coverage, pricing and context-tier details, and review dates.