Skip to content

fix: price Claude Code on OpenRouter, run the row default model - #287

Merged
popodidi merged 1 commit into
mainfrom
axe/task-2492--work
Dec 2, 2026
Merged

popodidi merged 1 commit into
mainfrom
axe/task-2492--work

Conversation

@popodidi

@popodidi popodidi commented Dec 2, 2026

Copy link
Copy Markdown
Owner

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 its costUSD (G6). It then falls back to usage::PRICES, which has no openrouter/* rows, so the run was stored as a known $0.

Fix: provider rows get a model_price lookup (provider.rs). OpenRouter's is the public GET https://openrouter.ai/api/v1/model/<id> (no key; data.pricing in 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-request overrides are 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_model is 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_MODEL to the row's default_model. Per the same docs, --model takes precedence over ANTHROPIC_MODEL, so a rule's model still wins. Other… has no default, so nothing is set for it.

docs/user: concepts/runtimes.md and concepts/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) and a_catalog_price_is_per_token_in_usd
  • a_claude_provider_login_replaces_the_last_and_is_a_bearer_only now asserts ANTHROPIC_MODEL for DeepSeek and OpenRouter

Ran locally: cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo test --locked.

🤖 Generated with Claude Code

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>
@popodidi
popodidi merged commit 1b9847c into main Dec 2, 2026
3 checks passed
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