You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cost tracking shows $0.00 for custom providers using @ai-sdk/openai-compatible even when cost fields are configured #24113
When using a custom provider configured via opencode.json with @ai-sdk/openai-compatible, the UI does not track or display $ Spent. The cost remains at $0.00 regardless of token usage, even when cost fields are explicitly configured per the config schema.
This is a similar issue to what was reported on the popular fork anomalyco/opencode#17223.
Plugins
No response
OpenCode version
1.14.22
Steps to reproduce
Configure a custom provider in opencode.json with @ai-sdk/openai-compatible and cost fields specified:
If this is indeed the same underlying issue, please consider adding your specific details (the @ai-sdk/openai-compatible configuration and x-litellm-response-cost header context) as a comment on #17223 instead.
Yes, duplicate of #17223:
Your values in the config are too low to create meaningful steps.
Try 0.3 as a cost for example, which is in $ per 1M tokens.
@maurerle was right about the cost scale — my values were per-token instead of per-1M-tokens. That fixed the $0.00 display.
However, I also had two related config gaps that left the UI broken even after fixing costs:
1. limit.context is required for the % usage display
OpenCode uses model.limit.context for the percentage calculation, notmodel.context_window. Without it, context always shows 0% regardless of actual token usage.
2. includeUsage: true is needed in provider options
When using @ai-sdk/openai-compatible with a LiteLLM proxy, streaming responses don't include token counts by default. Both cost and context tracking fail silently without this flag.
Activity
github-actions commentedon Apr 24, 2026
This issue might be a duplicate of existing issues. Please check:
If this is indeed the same underlying issue, please consider adding your specific details (the
@ai-sdk/openai-compatibleconfiguration andx-litellm-response-costheader context) as a comment on #17223 instead.maurerle commentedon May 8, 2026
Yes, duplicate of #17223:
Your values in the config are too low to create meaningful steps.
Try 0.3 as a cost for example, which is in $ per 1M tokens.
fabienbarbaud commentedon May 9, 2026
Update — confirmed fixed on my end.
@maurerle was right about the cost scale — my values were per-token instead of per-1M-tokens. That fixed the
$0.00display.However, I also had two related config gaps that left the UI broken even after fixing costs:
1.
limit.contextis required for the % usage displayOpenCode uses
model.limit.contextfor the percentage calculation, notmodel.context_window. Without it, context always shows0%regardless of actual token usage.2.
includeUsage: trueis needed in provider optionsWhen using
@ai-sdk/openai-compatiblewith a LiteLLM proxy, streaming responses don't include token counts by default. Both cost and context tracking fail silently without this flag.Full working config excerpt
{ "provider": { "litellm": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "https://proxy.example.com/v1", "includeUsage": true }, "models": { "my-model": { "limit": { "context": 202000, "output": 25344 }, "cost": { "input": 1.4, "output": 4.4 } } } } } }All three (cost scale, limit.context, includeUsage) were required to get cost tracking and context percentage working correctly.
Closing this as resolved — the underlying behavior could use better docs, but it's working as designed once configured properly.