feat(pricing): add models.dev fallback source - #665
Merged
IvGolovach merged 1 commit intoJun 4, 2026
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
1 issue found across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Validation * Validation tier: Tier 2R - post-review narrow runtime correction for models.dev retry failure handling. * git diff --check: PASS * git diff --cached --check: PASS * cargo test -p tokscale-core models_dev -- --nocapture: PASS, 8 tests * cargo test -p tokscale-core pricing:: PASS, 213 tests * cargo fmt --check: PASS * Ledger: not applicable - not required for selected validation tier/change family. * Version: not applicable - not required for selected validation tier/change family. * Not run: cargo check -p tokscale-cli - not required for this correction; touched code is internal to tokscale-core models.dev fetch handling and targeted pricing tests cover it. Rollback * git revert HEAD
IvGolovach
force-pushed
the
codex/models-dev-pricing-source-20260601
branch
from
June 1, 2026 22:35
b7226c8 to
37b5a06
Compare
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.
Summary
models.devas a third upstream pricing dataset alongside LiteLLM and OpenRouter.models.devdataset in the existing pricing cache layer and reuse stale cached data when live fetches are unavailable.models.devonly as a provider-aware fallback so custom overrides, LiteLLM, OpenRouter, and existing Cursor overrides keep their current precedence.models.devthroughtokscale pricing --provider models.devfor direct pricing inspection.Why
Tokscale can miss cost estimates when a newer model appears in
models.devbefore it is represented in LiteLLM or OpenRouter. That creates avoidable zero-cost or unknown-cost reports even when a usable public pricing source already exists. This change expands coverage while keeping the existing source ordering intact: the new dataset fills gaps, but it does not shadow custom overrides or the established primary sources.Diff scope
crates/tokscale-core/src/pricing/models_dev.rs: adds the fetch, cache, retry, parser, and per-million-to-per-token conversion for themodels.devAPI.crates/tokscale-core/src/pricing/mod.rs: loadsmodels.devin parallel with the existing pricing sources, includes stale-cache recovery, and adds fixture-backed coverage for fallback cost calculation.crates/tokscale-core/src/pricing/lookup.rs: wiresmodels.devinto exact, normalized, provider-aware, and prefix lookup paths after the existing primary sources.crates/tokscale-cli/src/main.rs: allowspricing --provider models.devand renders the source label consistently.crates/tokscale-core/tests/fixtures/models_dev_pricing.json: adds a focused fixture for parser and precedence tests.Branch integrity
maina86e688d620939d2c973c6d5625baa815ea223d7origin/main:0 behind / 1 aheada86e688d620939d2c973c6d5625baa815ea223d7Commit integrity
b7226c82827c7b8532803c3fdeb30467510f39d0 feat(pricing): add models.dev fallback sourceDiff hygiene
git diff --name-status origin/main...HEAD:M crates/tokscale-cli/src/main.rs,M crates/tokscale-core/src/pricing/lookup.rs,M crates/tokscale-core/src/pricing/mod.rs,A crates/tokscale-core/src/pricing/models_dev.rs,A crates/tokscale-core/tests/fixtures/models_dev_pricing.jsongit diff --check origin/main...HEAD: PASS, no outputValidation mode and proof
cargo test -p tokscale-core pricing::: PASS, 212 testscargo check -p tokscale-cli: PASScargo fmt --check: PASScurl -fsSL -A 'tokscale-pr-validation/1.0' https://models.dev/api.json | python3 -c '...': PASS, provider map with model objects and optional cost fieldsCI context confirmation
Runtime safety
models.devfails, preserving LiteLLM/OpenRouter behavior.models.dev.Migration notes
Not applicable - no DB migration changed.
Documentation integrity
Not applicable - no docs or runbooks changed. The CLI help text for
tokscale pricing --providerwas updated with the new valid source.Rollback plan
Rollback: revert this PR.
DB downgrade: not applicable.
Data repair: not applicable.
Operational caveats: reverting restores the previous LiteLLM/OpenRouter/custom-only pricing source set.
Known residual risks
models.devis an external best-effort data source; the implementation treats fetch or parse failures as non-fatal so existing pricing behavior remains available.Summary by cubic
Add
models.devas a provider-aware fallback pricing source to fill gaps whenLiteLLMorOpenRouterdon’t have a model. Also adds CLI support to query it withtokscale pricing --provider models.dev.New Features
models.devafter custom overrides,LiteLLM, andOpenRouter(exact/normalized/prefix, provider-aware) without changing precedence.tokscale pricing --provider models.devand updated provider validation/help.Bug Fixes
models.devto back off on 429/5xx and fail after max retries; still falls back to cached data when available.Written for commit 37b5a06. Summary will update on new commits.