Skip to content

feat: multi-provider pricing and custom rate overrides#101

Merged
rajkumarsakthivel merged 5 commits into
mainfrom
fix/multi-model-pricing
Jun 15, 2026
Merged

feat: multi-provider pricing and custom rate overrides#101
rajkumarsakthivel merged 5 commits into
mainfrom
fix/multi-model-pricing

Conversation

@rajkumarsakthivel

Copy link
Copy Markdown
Member

Summary

  • Added static pricing for 15 models across OpenAI, Google, and Anthropic so savings estimates work for non-Claude users
  • Added pricing.input and pricing.output config overrides in cce.toml for unlisted or custom-priced models
  • Dashboard savings page now shows estimated cost saved, active pricing model, and rates
  • Anthropic pricing still auto-fetches from docs (live data wins over static fallbacks)

Example cce.toml configs:

# Use a known model
[pricing]
model = "gpt-4o"

# Override rates for any model
[pricing]
model = "deepseek-v3"
input = 0.27
output = 1.10

Closes #99

Savings estimates were locked to Anthropic model pricing, showing wrong
numbers for users on GPT-4o, Gemini, etc. Now supports 15 models across
three providers with static fallbacks, and users can override rates via
pricing.input/pricing.output in cce.toml for unlisted models.

Dashboard savings page now shows estimated cost saved with the active
pricing model and rates.

Closes #99
Use TYPE_CHECKING import for Config to satisfy both F821 (undefined name)
and F401 (unused import) rules.
fazleelahhee
fazleelahhee previously approved these changes Jun 11, 2026
@rajkumarsakthivel

Copy link
Copy Markdown
Member Author

Screenshot

Dashboard Savings

New "Est. Cost Saved" card showing $11.18 saved at opus rates. Pricing note below shows active model and rates with config hint.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds multi-provider model pricing support so savings/cost estimates work beyond Anthropic defaults, with config-driven model selection and per-rate overrides, and surfaces this information in both CLI and dashboard.

Changes:

  • Introduces static pricing for multiple OpenAI/Google/Anthropic models and merges it with live-fetched Anthropic pricing (cache-backed).
  • Adds pricing.input / pricing.output overrides to config and uses a shared resolve_pricing() helper in CLI/dashboard.
  • Extends the dashboard savings API/UI and updates tests accordingly.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/test_cli_smoke.py Updates pricing fallback expectations and asserts presence of non-Anthropic models.
tests/dashboard/test_server.py Extends /api/savings assertions to include pricing metadata and cost saved.
src/context_engine/pricing.py Adds static multi-provider pricing, merged lookup behavior, and resolve_pricing() / list_available_models().
src/context_engine/dashboard/server.py Adds pricing/cost fields to /api/savings.
src/context_engine/dashboard/_page.py Updates Savings page UI to show estimated cost saved and pricing note.
src/context_engine/config.py Adds optional pricing rate override fields and config mapping/type validation.
src/context_engine/cli.py Switches savings reporting to use centralized resolve_pricing().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/context_engine/pricing.py Outdated
Comment thread src/context_engine/pricing.py Outdated
Comment thread src/context_engine/config.py
Comment thread src/context_engine/dashboard/_page.py Outdated
Comment thread src/context_engine/dashboard/server.py
Comment thread tests/dashboard/test_server.py
Comment thread tests/dashboard/test_server.py
- list_available_models() no longer triggers network fetch
- resolve_pricing() strips whitespace, shows fallback label when model unknown
- Config accepts None for pricing_input/pricing_output (YAML null)
- Dashboard pricing note references correct config file paths
- Dashboard /api/savings uses fetch_live=False to avoid request-path latency
- Savings tests patched to be hermetic (no network/cache side effects)
@rajkumarsakthivel rajkumarsakthivel merged commit 24bab38 into main Jun 15, 2026
19 checks passed
@rajkumarsakthivel rajkumarsakthivel deleted the fix/multi-model-pricing branch June 15, 2026 18:41
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/savings calculator assumes Claude model pricing

3 participants