SIGN IN SIGN UP

fix(plugin): map real pricing from /v1/model/info into cost field (#16)

toConfigModel() never read input_cost_per_token/output_cost_per_token
from LiteLLM's /v1/model/info response, so every discovered model
landed in opencode.json without a cost field. OpenCode's own default
(0) then made every call look free in the picker and in `/cost`,
regardless of what the proxy actually billed.

Map those two fields into OpenCode's cost block, converting LiteLLM's
USD-per-token to OpenCode's USD-per-million-token convention. Models
LiteLLM has no price anchor for (e.g. rerank) are left without a cost
field, same as before — this reports real prices, it doesn't invent
ones for models that don't have one.

Verified live against a self-hosted LiteLLM proxy: discovered cost
matched litellm's own model_info exactly across 15 priced models, and
a real chat completion's session cost matched
prompt_tokens * input_cost_per_token + completion_tokens *
output_cost_per_token to the cent.
C
Cleverson Sacramento committed
907b496a1547e3ecf842feaa0570da660e4a5f90
Parent: baa8874
Committed by GitHub <noreply@github.com> on 8/4/2026, 9:31:08 PM