Skip to content

pricing: price an OpenRouter model variant as its model - #315

Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
microsoft:mainfrom
Shizoqua:fix-pricing-openrouter-variants
Open

Lanre Shittu (Shizoqua) wants to merge 1 commit into
microsoft:mainfrom
Shizoqua:fix-pricing-openrouter-variants

Conversation

@Shizoqua

Copy link
Copy Markdown
Contributor

resolve_model drops a router's provider prefix (openai/gpt-6.1-sol is gpt-6.1-sol), since the prefix names a route, not a price. OpenRouter also adds a variant after a colon: :free, :nitro, :floor, :online. Its SDK documentation says it "Supports variant suffixes (e.g. openai/gpt-4:free)". The variant chooses how the request is routed or billed, not the model, but it was kept. So openai/gpt-6.1-sol:nitro found no price: weights_for raised, and the ledger priced the session on the fallback curve (0.10x cache hits and 6x output, where gpt-6.1-sol is 0.05x and 5x). Claude ids escaped only because they are matched by substring.

Fix: the variant is dropped with the provider. No price-table key holds a colon, so this changes only ids that had no price. A colon in an id no router named (llama3:8b) is left as it is, and an unknown model still fails loudly. The change is in resolve_model; the branch merges with the open #309, which edits weights_for.

Tests, in a new tests/test_pricing_router_variants.py:

  • five routed variants (:nitro, :floor, :free, :online, :thinking) resolve to their model and are priced by its table, the same as the bare model (all fail on main);
  • an id with no router keeps its colon;
  • an unknown routed model with a variant still raises.
python -m pytest tests -n 4 --dist worksteal -rfEs --tb=line
1408 passed, 41 skipped

The skips need Windows, a real agent CLI (Codex, Hermes, opencode) or aider, or a non-root user.

Fixes #313

`resolve_model` drops a router's provider prefix (`openai/gpt-6.1-sol` is `gpt-6.1-sol`), since
the prefix names a route, not a price. OpenRouter also adds a variant after a colon: `:free`,
`:nitro`, `:floor`, `:online` (its SDK documentation: "Supports variant suffixes (e.g.
openai/gpt-4:free)"). The variant chooses how the request is routed or billed, not the model, but
it was kept, so `openai/gpt-6.1-sol:nitro` found no price: `weights_for` raised, and the ledger
priced the session on the fallback curve (0.10x cache hits and 6x output, where gpt-6.1-sol is
0.05x and 5x). Claude ids escaped only because they are matched by substring.

The variant is now dropped with the provider. No price-table key holds a colon, so this changes
only ids that had no price; a colon in an id no router named (`llama3:8b`) is left as it is, and
an unknown model still fails loudly.
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.

pricing: an OpenRouter model variant such as openai/gpt-6.1-sol:nitro is priced on the fallback curve

1 participant