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
fix(llm): LiteLLM proxy responses record $0.00 cost when x-litellm-response-cost header is omitted #51958
When using OpenCode with a LiteLLM proxy (e.g. litellm/gpt-6-luna), some responses are recorded with $0.00 cost even though the proxy correctly billed the request.
Root cause
LiteLLM 1.98+ omits the x-litellm-response-cost response header when its value equals x-litellm-response-cost-original (a deduplication optimisation). However, OpenCode does not read any LiteLLM response headers at all — cost is estimated purely from token counts and a local price table.
For models without a price entry in the local config, this produces $0.00. For models with a price entry but where the header is absent, the local estimate may differ from the proxy's actual billing.
Steps to reproduce
Configure OpenCode with a LiteLLM provider (e.g. a self-hosted proxy or prophet-router)
Send two identical consecutive requests with the same model
Check opencode stats — one or both may show $0.00 for that model
Observed vs expected
Observed:opencode stats shows $0.00 for LiteLLM-routed models
Expected: cost matches x-litellm-response-cost (or x-litellm-response-cost-original) from the proxy response headers
Evidence
Two manual curl calls to the proxy with identical payloads:
Please use the Bug Report template's required Description field (the current report uses a Bug heading instead) and add your OpenCode version and operating system/system details.
Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
#43818: requests honoring provider-reported costs from gateways including LiteLLM.
#24113: reports zero costs for a custom LiteLLM proxy and notes that OpenCode does not read its cost response header.
If you believe this was flagged incorrectly, please let a maintainer know.
Activity
github-actions commentedon Sep 28, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
If you believe this was flagged incorrectly, please let a maintainer know.
github-actions commentedon Sep 29, 2026
This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.
Feel free to open a new issue that follows our issue templates.