Skip to content

fix(model-prices): prioritize official pricing sources - #460

Merged
seakee merged 4 commits into
mainfrom
fix/models-dev-official-price-matching
Jul 30, 2026
Merged

fix(model-prices): prioritize official pricing sources#460
seakee merged 4 commits into
mainfrom
fix/models-dev-official-price-matching

Conversation

@seakee

@seakee seakee commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Summary

Use canonical model metadata from the models.dev catalog to select first-party prices before falling back to LiteLLM and OpenRouter.
Keep ambiguous or fuzzy matches in the manual confirmation flow and preserve candidates from every source.

Scope

  • Frontend panel
  • Manager Server
  • CPA panel mode
  • Full Docker mode
  • Native packages / release
  • Docs / Wiki
  • CI / build / tooling

Changes

  • Switch the production models.dev source to catalog.json and retain canonical model metadata through ETag cache reuse.
  • Match prices in models.dev, LiteLLM, then OpenRouter order; reject incomplete catalogs and never auto-save fuzzy matches.
  • Keep confirmation candidates distinct by source, group them in the frontend, and document the updated behavior in both manuals.

User Impact

Official first-party models.dev prices are selected automatically when available. Ambiguous sources now fall through in priority order, while unresolved models show source-separated confirmation options instead of losing same-ID alternatives.

Compatibility / Runtime Notes

  • CPA panel mode: No behavior change; model-price synchronization remains a Manager Server capability.
  • Manager Server mode: The default models.dev URL changes from api.json to catalog.json; legacy payload decoding remains supported.
  • Full Docker / native packages: The same Manager Server behavior applies with no configuration or migration requirement.

Data / Security Notes

N/A. This change does not alter the SQLite schema, credentials, management keys, logs, raw usage data, or plugin behavior. Existing stored prices are only changed when the user triggers synchronization or confirms a candidate.

Risk / Rollback

Risk level: Medium

Rollback notes: Revert the four commits in this PR to restore the previous endpoint and matching behavior. Existing model prices remain intact unless a synchronization was explicitly triggered.

Verification

  • Type check
  • Lint
  • Tests
  • Build
  • Manual UI check
  • Docs/link check
  • Not applicable, docs-only

Commands / evidence:

npm run type-check
npm run lint
npm run test
npm run manager-server:test
go vet ./...
go test -race -shuffle=on -count=3 ./internal/service/modelprice
go test -count=1 -run TestModelPricesSyncUsesModelsDevOfficialAndOrderedFallback ./internal/httpapi
go test -count=1 -run TestModelPricesSyncCachesModelsDevAndSkipsCoveredFallbacks ./internal/httpapi
go test -count=1 -run TestModelPricesSyncFromLiteLLMFormat ./internal/httpapi
git diff --check

The frontend suite passed 1,214 tests across 131 files. The focused candidate model test passed 10/10.

Screenshots / Recordings

N/A. No screenshot was captured; the visible change is limited to grouping native select options by price source, with candidate identity and grouping covered by focused tests.

Docs

  • README / README_CN updated for user-visible capabilities
  • Matching docs manual and navigation updated
  • Demo fixtures, screenshots, and deep links reviewed
  • Release notes needed
  • Not needed — explanation included below

Docs decision: Updated the Chinese and English model-price manuals. Existing navigation already links to these pages and required no code change.

Related

N/A

seakee added 4 commits July 30, 2026 12:09
Read models.dev catalog metadata and select canonical first-party prices before ordered LiteLLM and OpenRouter fallbacks.

Keep ambiguous and fuzzy matches out of automatic persistence while preserving candidates from every source. Reject incomplete catalogs and retain cache metadata so third-party entries cannot silently become official prices.
Switch production model-price synchronization from the legacy api.json endpoint to catalog.json.

The catalog exposes canonical model identities required for official-price selection. Legacy payload decoding remains supported for compatibility.
Key candidate selections by source and model ID instead of model ID alone.

Group confirmation options by provider so identical IDs from multiple sources remain selectable. This only changes unresolved-price confirmation behavior.
Document models.dev, LiteLLM, and OpenRouter precedence in the Chinese and English manuals.

Clarify official catalog selection, ambiguity fallback, and source-separated confirmation. No runtime behavior changes are included in this commit.
@seakee
seakee merged commit 8ee0749 into main Jul 30, 2026
10 checks passed
@seakee
seakee deleted the fix/models-dev-official-price-matching branch July 30, 2026 06:31
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