GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Cost tracking ($ Spent) does not work for custom provider models · Issue #17223 · anomalyco/opencode

Cost tracking ($ Spent) does not work for custom provider models #17223

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Cost tracking ($ Spent) does not work for custom provider models#17223
Copy link
Assignees
rekram1-node

Description

@delflein
delflein
opened on Mar 12, 2026
Issue body actions

Problem

When using a custom provider configured via opencode.jsonc with @ai-sdk/openai-compatible, the UI does not track or display $ Spent. The cost remains at $0.00 regardless of token usage.

Built-in providers get their pricing data from models.dev and cost tracking works for those. For custom providers, the cost config fields are available in the schema but do not appear to have any effect on the UI.

Steps to Reproduce

  1. Configure a custom provider in opencode.jsonc with cost fields specified per the config schema:
{
  "provider": {
    "my-provider": {
      "name": "My Provider",
      "npm": "@ai-sdk/openai-compatible",
      "models": {
        "my-model": {
          "name": "My Model",
          "cost": {
            "input": 0.0000055,
            "output": 0.0000275,
            "cache_read": 5.5e-7,
            "cache_write": 0.000006875
          },
          "limit": { "context": 200000, "output": 64000, "input": 200000 },
          "tool_call": true
        }
      },
      "options": {
        "baseURL": "https://my-proxy.example.com"
      }
    }
  }
}
  1. Start a session using the custom provider model.
  2. Send messages and observe the cost display in the UI.

Expected Behavior

The UI calculates and displays a running cost using the cost values defined in the model config and the token usage from the response.

Actual Behavior

$ Spent remains at $0.00 for the entire session. The cost config fields on custom provider models have no observable effect.

Environment

  • Custom provider backed by a LiteLLM proxy via @ai-sdk/openai-compatible
  • Multiple models tested — issue is consistent across all custom provider models
  • cost structure matches the config JSON schema at https://opencode.ai/config.json, including input, output, cache_read, cache_write, and context_over_200k sub-fields
Reacted by Jessica Köhnke, Juan Abia, Codinator007, Stefano Ciarcià, nguyendown, Mark Nguyen, Michael Monaghan, Jose Constela, Matt Sawyer, Wieland Strauß and 16 more

Activity

  1. github-actions
    assigned
    rekram1-node
    on Mar 12, 2026
  2. github-actions
    added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 12, 2026
  3. mollux commented on Mar 21, 2026

    @mollux
    mollux
    on Mar 21, 2026
    More actions

    @delflein I made a PR to address this, see #17645, does this also solve your problem?

  4. nstoeckigt commented on Mar 31, 2026

    @nstoeckigt
    nstoeckigt
    on Mar 31, 2026
    More actions

    Reproducing with LiteLLM as a proxy

    I'm running OpenCode with LiteLLM as an intermediate proxy to Anthropic (claude). The model is configured as a custom provider using litellm/anthropic/claude as the model ID.

    Setup:

    • OpenCode connects to a local LiteLLM instance
    • LiteLLM forwards requests to Anthropic
    • Provider configured as a custom openai-compatible provider pointing to the LiteLLM endpoint

    Observed behavior:

    • Token counts (input/output) are displayed correctly in the OpenCode session overview
    • spent $ remains at $0.00 for every session

    Expected behavior:

    • spent $ should reflect the actual cost of the session

    Workaround:

    • LiteLLM's own dashboard correctly tracks and displays costs — currently using that as the only reliable cost tracking source

    Root cause (suspected):
    OpenCode receives token counts from the LiteLLM response but has no way to map them to a cost since it doesn't know the pricing for the underlying model behind the proxy. LiteLLM does return cost information in its response metadata (e.g. x-litellm-response-cost header and usage.cost in some response formats) — it would be great if OpenCode could pick that up when available.

    Reacted by Michael Monaghan, Michał Polewczak, Justin Travaille, Calle Kabo, Vlad Goldman, darenegade, Jens Grehling, Ryan Beall, Evan, Martin Honermeyer and 3 more
  5. code-yeongyu
    added 8 commits that reference this issue on Apr 25, 2026

    roadmap: #213 filed — OpenAiUsage struct does not deserialize prompt_…

    347102d

    roadmap: #213 filed — OpenAiUsage struct does not deserialize prompt_…

    be52022

    roadmap: #213 filed — OpenAiUsage struct does not deserialize prompt_…

    e07f5cd

    roadmap: #213 filed — OpenAiUsage struct does not deserialize prompt_…

    5f9fa9c

    roadmap: #213 filed — OpenAiUsage struct does not deserialize prompt_…

    086a266

    roadmap: ultraworkers#213 filed — OpenAiUsage struct does not deseria…

    0bf318a

    roadmap: #213 filed — OpenAiUsage struct does not deserialize prompt_…

    10a91b9

    roadmap: #213 filed — OpenAiUsage struct does not deserialize prompt_…

    316dcfb
  6. thdxr
    removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  7. maurerle commented on May 8, 2026

    @maurerle
    maurerle
    on May 8, 2026
    More actions

    @delflein I can not reproduce this issue.
    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.

    @nstoeckigt respecting x-litellm-response-cost headers is a different feature request.

  8. JGuck commented on May 28, 2026

    @JGuck
    JGuck
    on May 28, 2026
    More actions

    I can confirm that cost calculation is working when realizing costs are per M token.

  9. laiweihwa commented on Jun 19, 2026

    @laiweihwa
    laiweihwa
    on Jun 19, 2026
    More actions

    My custom provider returns cost and opencode ignores it. I believe opencode-plugin-litellm is to blame, in my case.

  10. github-actions commented on Aug 19, 2026

    @github-actions
    github-actionsBot
    on Aug 19, 2026 – with GitHub Actions
    Contributor
    More actions

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  11. github-actions
    closed this as not plannedon Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.