Skip to content

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

Open

Description

resolve_model in tokeneconomizer/pricing.py drops a router's provider prefix, because "a router's provider/model id 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)" and that "Non-default variants include a :variant suffix".

The variant chooses how the request is routed or billed, not which model runs, but it is kept. So openai/gpt-6.1-sol:nitro finds no price: weights_for raises, and the plugin's ledger prices 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 escape only because they are matched by substring.

Reproduction (offline):

from tokeneconomizer import pricing
from tokeneconomizer.plugin import accounting

usage = {"input_tokens": 100, "cache_read_input_tokens": 10_000,
         "cache_creation_input_tokens": 0, "output_tokens": 10}
for model in ["openai/gpt-6.1-sol", "openai/gpt-6.1-sol:nitro"]:
    print(model, "->", accounting.effective(dict(usage, model=model)))

Expected: the same (650.0, 'model') for both
Actual: (650.0, 'model') for the model, (1160.0, 'fallback') for its :nitro variant

Upstream main: 1bfeccd
Python 3.13.18, Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions