Skip to content

fix(provider): apply config model cost overrides at runtime#17645

Open
mollux wants to merge 1 commit intoanomalyco:devfrom
mollux:fix/runtime-model-cost-config-override
Open

fix(provider): apply config model cost overrides at runtime#17645
mollux wants to merge 1 commit intoanomalyco:devfrom
mollux:fix/runtime-model-cost-config-override

Conversation

@mollux
Copy link
Copy Markdown

@mollux mollux commented Mar 15, 2026

Issue for this PR

Closes #17223

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes a runtime gap where model prices from config could be present in resolved config but not applied on the final model object used for usage/cost calculations.
The change applies config model cost overrides during provider model finalization so cost values are consistently present before runtime usage math runs.

How did you verify your code works?

  • Added/updated provider test coverage for model cost override behavior via config content.
  • Ran focused tests locally:
bun test test/provider/provider.test.ts -t "OPENCODE_CONFIG_CONTENT overrides cost for configured model|model cost overrides existing cost values"

Screenshots / recordings

N/A (non-UI change)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@mollux mollux marked this pull request as ready for review March 21, 2026 16:51
@jabr
Copy link
Copy Markdown

jabr commented Mar 25, 2026

Any chance this will be merged soon? I use API accounts directly with providers that are often missing from the standard models.dev data, and thus specify most of my model configs (and pricing info) directly in my opencode.json config. This means that OpenCode's cost estimates are wildly inaccurate for me, even though the token usage counts are correct.

In this example, it appears to be pricing the cached reads at $0 even though I have the correct config for $0.06/Mtok. The 1.5M input + 68.7K output looks to equal the $0.54 total it reports, but it's missing $0.66 of cached read cost:

┌────────────────────────────────────────────────────────┐
│                      MODEL USAGE                       │
├────────────────────────────────────────────────────────┤
│ novita-ai/novita-ai/minimax/minimax-m2.7               │
│  Messages                                          216 │
│  Input Tokens                                     1.5M │
│  Output Tokens                                   68.7K │
│  Cache Read                                      11.0M │
│  Cache Write                                         0 │
│  Cost                                          $0.5447 │
└────────────────────────────────────────────────────────┘

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.

Cost tracking ($ Spent) does not work for custom provider models

2 participants