feat(runtimes): add cost details for OpenCode models (multi-provider pricing)#1908
Open
sapk wants to merge 3 commits intomultica-ai:mainfrom
Open
feat(runtimes): add cost details for OpenCode models (multi-provider pricing)#1908sapk wants to merge 3 commits intomultica-ai:mainfrom
sapk wants to merge 3 commits intomultica-ai:mainfrom
Conversation
|
@sapk is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
OpenCode runs reported $0.00 cost in the runtime "Cost by agent" tab because the client-side pricing table was Anthropic-only and keyed by bare model id, while OpenCode emits `provider/model` strings (e.g. `openai/gpt-4o`, `anthropic/claude-sonnet-4-5`). - Generate `packages/views/runtimes/pricing.generated.ts` from `https://models.dev/api.json` (MIT, the dataset OpenCode uses internally). Snapshot covers anthropic, openai, google, moonshotai, opencode, opencode-go — the providers Multica's runtime presets emit. - Replace the hand-curated `MODEL_PRICING` table in `utils.ts` with a lookup against the generated `PRICING` map; an internal adapter converts the snake_case `ModelCost` shape to the camelCase `{ cacheRead, cacheWrite }` shape the cost-estimation functions consume, defaulting missing cache tiers to `input` (conservative — preserves correct totals for daemon-synthesised cache_write_tokens and keeps `estimateCacheSavings` returning 0 for providers without a cache discount). - Resolver flow: exact `provider/model` match, otherwise iterate every PRICING entry's bare key and match either `keyBare === bare` or `keyBare.startsWith(withoutDate)`. Catches bare model names (`gpt-4o`), bare with date suffix (`claude-opus-4-1-20260105`), and provider-prefixed with date suffix (`anthropic/claude-opus-4-1-20260105`). - Regenerate via `node scripts/generate-pricing.mjs` whenever upstream prices drift. Closes [MUL-1](mention://issue/a0010234-64a6-4c06-a0b1-27de095cb8a9)
c499637 to
e70552e
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.
What does this PR do?
Fixes the $0.00 cost display for OpenCode runs by adding multi-provider model pricing support (OpenAI, Google, Anthropic, etc.) from models.dev.
Related Issue
none
Type of Change
Changes Made
How to Test
Checklist
AI Disclosure
AI tool used: Claude Code, Cursor, Multica Agent, Opencode
Prompt / approach:
I wanted to evaluate multica in a usefull way by fixing with it a bug/missing feature I found when testing.
I simply chat with Claude in multica to create agents needed to solve and setup a dedicated issue to fix it.
Screenshots (optional)
before
after