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
When using @ai-sdk/openai with a custom baseURL pointing to an OpenAI-compatible proxy, the status bar always displays 0% used and $0.00 spent. Token usage is never tracked despite the upstream API returning valid usage data.
Both were tested via Postman against the same proxy endpoint. The usage field is present and correctly populated.
Expected Behavior
OpenCode should parse the usage field from the response.completed SSE event (streaming) or the response body (non-streaming) and reflect it in the status bar.
Actual Behavior
Status bar shows 0% used / $0.00 spent regardless of actual token consumption. Auto-compaction based on context usage may also be affected.
Notes
This is specific to @ai-sdk/openai (Responses API, /v1/responses). The existing fix for @ai-sdk/openai-compatible (includeUsage: true, see Context usage count is always 0 for some local openai-compatible providers #423) does not apply here, as the Responses API uses a different streaming format (response.completed event vs stream_options).
The proxy correctly follows the OpenAI Responses API spec.
Description
When using
@ai-sdk/openaiwith a custombaseURLpointing to an OpenAI-compatible proxy, the status bar always displays0% usedand$0.00 spent. Token usage is never tracked despite the upstream API returning valid usage data.Configuration
{ "provider": { "my-provider": { "npm": "@ai-sdk/openai", "options": { "baseURL": "https://my-proxy.example.com/v1" }, "models": { "gpt-5.4": { "name": "gpt-5.4" } } } } }Steps to Reproduce
@ai-sdk/openaiwith a custombaseURLVerification
I verified the upstream API returns valid
usagedata in both non-streaming and streaming modes.Non-streaming response (excerpt)
{ "usage": { "input_tokens": 18, "input_tokens_details": { "cached_tokens": 0 }, "output_tokens": 13, "output_tokens_details": { "reasoning_tokens": 0 }, "total_tokens": 31 } }Streaming —
response.completedevent (excerpt){ "type": "response.completed", "response": { "status": "completed", "usage": { "input_tokens": 18, "input_tokens_details": { "cached_tokens": 0 }, "output_tokens": 13, "output_tokens_details": { "reasoning_tokens": 0 }, "total_tokens": 31 } } }Both were tested via Postman against the same proxy endpoint. The
usagefield is present and correctly populated.Expected Behavior
OpenCode should parse the
usagefield from theresponse.completedSSE event (streaming) or the response body (non-streaming) and reflect it in the status bar.Actual Behavior
Status bar shows
0% used/$0.00 spentregardless of actual token consumption. Auto-compaction based on context usage may also be affected.Notes
@ai-sdk/openai(Responses API,/v1/responses). The existing fix for@ai-sdk/openai-compatible(includeUsage: true, see Context usage count is always 0 for some local openai-compatible providers #423) does not apply here, as the Responses API uses a different streaming format (response.completedevent vsstream_options).Environment