Skip to content

feat(provider): expose reference cost multiplier settings - #566

Open
DemosHume wants to merge 1 commit into
SaladDay:mainfrom
DemosHume:feat/provider-cost-multiplier
Open

DemosHume wants to merge 1 commit into
SaladDay:mainfrom
DemosHume:feat/provider-cost-multiplier

Conversation

@DemosHume

Copy link
Copy Markdown

The proxy already honors meta.costMultiplier, but users cannot edit it in the provider form. Expose a provider-wide reference cost multiplier for Claude, Codex and Gemini, so a relay charging half of reference prices can be configured as 0.5 for all models.

cc-switch --app codex provider cost-multiplier PROVIDER_ID 0.5
cc-switch --app codex provider cost-multiplier PROVIDER_ID inherit
  • Add a field to provider add/edit forms and a noninteractive command. Validate decimal values from 0 to 1000, including on the save shortcut. Blank or inherit restores the existing app-default behavior.
  • The direct command changes only the selected provider/app's metadata in an immediate transaction; unrelated metadata and live configuration are preserved.
  • Reuse existing request/provider snapshot accounting: the multiplier applies once to total reference cost, including caches. Token counts and already-priced history remain unchanged. Offline sessions without provider attribution are excluded.
  • Include English/Chinese contextual help and README examples. No schema changes or changes to the pricing-sync PR (feat(pricing): sync reference model prices from models.dev #565).

Validation on Linux with pinned Rust 1.91.1:

  • cargo fmt --check passed.
  • cargo test --locked provider_cost_multiplier --lib: 4 passed (form roundtrip/reset, actual save shortcut rejection, scoped metadata persistence and resolution, all-model/cache accounting).
  • cargo test --locked cli::tui::form::tests --lib: 239 passed.
  • cargo test --locked proxy::usage::calculator::tests --lib: 7 passed.
  • cargo clippy --locked -- -A clippy::reversed_empty_ranges passed with existing warnings. The allow targets the pre-existing zero-length range in home_chart.rs, which blocks ordinary Clippy on this base.
  • Windows compile check passed; Linux was used for unit tests because existing Windows test code contains unguarded Unix imports.
  • Two independent review rounds completed with no remaining findings.

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