Repository navigation
fix: price Claude Code on OpenRouter, run the row default model - #287
Merged
Merged
Conversation
Two defects from the Claude Code + DeepSeek trial (axe task 2390): - A Claude Code run on a provider login whose model had no price row was recorded as a known $0 (Claude's own costUSD is untrusted there). The node now prices such a model at the provider's public price when the provider row has a lookup (OpenRouter GET /api/v1/model/<id>, no key, cached an hour per model), so OpenRouter models are no longer $0. - A Claude Code run on a provider login with no rule naming a model ran Claude Code's default (its Opus alias), which on OpenRouter is the row's Opus tier. The login now sets ANTHROPIC_MODEL to the row's default_model as documented for every provider login; a rule's --model still wins. docs/user updated for both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes defects 1 and 3 from the Claude Code + DeepSeek trial report (axe task 2390, store doc
harvis/research/20261202-claude-code-deepseek-trial.md). Task 2492.(a) $0 cost for Claude Code on an unpriced provider model
Root cause: on a provider login Claude Code reports
costBasis: "unknown", so axe correctly drops itscostUSD(G6). It then falls back tousage::PRICES, which has noopenrouter/*rows, so the run was stored as a known $0.Fix: provider rows get a
model_pricelookup (provider.rs). OpenRouter's is the publicGET https://openrouter.ai/api/v1/model/<id>(no key;data.pricingin USD per token as strings, per https://openrouter.ai/docs/guides/overview/models). When a model has no trusted tool cost and no table row, the node prices it at that price (Parsed::priced_by,provider::ModelPrices, cached 1h, failed lookups cached 10m, 5s timeout). It applies the default-conditions price only; per-requestoverridesare not applied. If the lookup fails, the model stays at $0 as before, and the docs say so.(c) An unpinned Claude runtime on OpenRouter runs Opus
Root cause:
default_modelis documented as "the model a runtime with this provider uses when a rule names none", but Claude Code never received it. With no--model, Claude Code runs its own default, the Opus alias (https://code.claude.com/docs/en/model-config). On OpenRouter that resolved to the row's Opus tier (~anthropic/claude-opus-latest).Fix: a Claude provider login now also sets
ANTHROPIC_MODELto the row'sdefault_model. Per the same docs,--modeltakes precedence overANTHROPIC_MODEL, so a rule's model still wins.Other…has no default, so nothing is set for it.docs/user:
concepts/runtimes.mdandconcepts/routines-bots-goals.md.Tests
provider::tests::a_model_price_is_looked_up_once_without_a_key(mock: path, no Authorization header, cache, 404)usage.rs:claude_code_on_openrouter_is_priced_at_openrouters_price(resumed-session deltas are non-zero; table rows, trusted figures and other providers are never looked up) anda_catalog_price_is_per_token_in_usda_claude_provider_login_replaces_the_last_and_is_a_bearer_onlynow assertsANTHROPIC_MODELfor DeepSeek and OpenRouterRan locally:
cargo fmt --check,cargo clippy --locked --all-targets -- -D warnings,cargo test --locked.🤖 Generated with Claude Code