Skip to content

LiteLLM proxy responses record $0.00 cost when x-litellm-response-cost header is omitted #52127

Closed as not planned

Description

@BrunoSilva-neuro

Description

When using OpenCode with a LiteLLM proxy, some turns are recorded with $0.00 cost in opencode stats even though the proxy correctly billed the request.

LiteLLM 1.98+ omits the x-litellm-response-cost response header when its value equals x-litellm-response-cost-original (a size optimisation). OpenCode does not read any LiteLLM response headers — cost is estimated purely from a local price table. For models with no price entry, this always yields $0.00. Two manual curl calls to the proxy with identical payloads confirmed the issue: request 1 returned x-litellm-response-cost: 0.000434; request 2 omitted that header but included x-litellm-response-cost-original: 0.000434, yet x-litellm-key-spend incremented on both.

Steps to reproduce

  1. Configure OpenCode with a LiteLLM provider (custom proxy or hosted router)
  2. Send a prompt using a model that has no local price entry (e.g. litellm/gpt-6-luna)
  3. Run opencode stats — cost for that model shows $0.00

Screenshot and/or share link

N/A

OpenCode version

1.18.30

Operating System

Windows 10 Enterprise 25H2 (Build 26200)

Terminal

Windows Terminal

Activity

  1. github-actions commented on Sep 29, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of an existing issue. Please check:

    • #51958: Reports the same LiteLLM response-cost header omission causing OpenCode to record $0.00 cost.
  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions