feat: pass through cost + limit metadata from /v1/models #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/cost-limit-passthrough"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
costandlimitmetadata from aor'sGET /v1/modelsresponse and inject them into opencode's per-model config via theconfighook.$ spent(computed client-side from tokens × pricing) and% context used(computed from tokens / context limit).Changes
src/index.ts: UpdatedModelEntrytype to capturecostandlimitfrom the/v1/modelsresponse. UpdateddiscoverModelsto pass them through asDiscoveredModelentries. Theconfighook injects them into each model's config entry.README.md: New "Cost tracking & context window" section documenting how the passthrough works and the v2 runnercost: 0caveat.How it works
opencode's config provider builder (
packages/opencode/src/provider/provider.ts:1463-1476) reads per-modelcostandlimitfrom the config we inject:opencode computes cost entirely client-side (
Session.getUsage— tokens × pricing / 1M). It does NOT read cost from response bodies. So injecting pricing via config is the correct and only channel.Depends on
aor PR #5 (
trevin/feat/model-limits-cost-metadata) — adds thecostandlimitfields to aor's/v1/modelsresponse.