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 — [BUG] Cost tracking shows $0.00 for Chinese model providers (GLM, DeepSeek, Qwen, MiMo) via @ai-sdk/openai-compatible · Issue #34877 · anomalyco/opencode

[BUG] Cost tracking shows $0.00 for Chinese model providers (GLM, DeepSeek, Qwen, MiMo) via @ai-sdk/openai-compatible #34877

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
[BUG] Cost tracking shows $0.00 for Chinese model providers (GLM, DeepSeek, Qwen, MiMo) via @ai-sdk/openai-compatible#34877
Copy link
Assignees
nexxeln
Labels
pending closetriaging

Description

@hyqf98
hyqf98
opened on Jul 2, 2026
Issue body actions

Description

When using Chinese model providers configured via opencode.json with @ai-sdk/openai-compatible, the TUI 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 significant pain point for users in China who rely on providers like Zhipu (GLM-5.2), DeepSeek (V4 Pro), Xiaomi (MiMo), Alibaba (Qwen), etc. — none of which use Anthropic/OpenAI native APIs.

Related

  • Existing PR with fix: fix(provider): apply config model cost overrides at runtime #17645 (open since March 2026, 4+ months)
  • Duplicate issues: Cost tracking shows $0.00 for custom providers using @ai-sdk/openai-compatible even when cost fields are configured #24113, Cost tracking ($ Spent) does not work for custom provider models #17223
  • Feature request for TUI display: [FEATURE]: Display token usage information in the TUI #13003

Steps to reproduce

  1. Configure a Chinese model provider in opencode.json:
{
  "provider": {
    "modelhub": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "apiKey": "sk-...",
        "baseURL": "https://modelhub.example.com/v1"
      },
      "models": {
        "glm-5.2": {
          "name": "glm-5.2",
          "cost": {
            "input": 0.000001178,
            "output": 0.000004123
          },
          "limit": {
            "context": 1000000
          }
        }
      }
    }
  },
  "model": "modelhub/glm-5.2"
}
  1. Start a session and send messages.
  2. Observe the cost display in the TUI status bar — it stays at $0.00.

Expected Behavior

OpenCode should calculate cost using the cost fields defined in the model config combined with token usage from the API response (usage.prompt_tokens, usage.completion_tokens).

Actual Behavior

  • $ Spent remains at $0.00 for the entire session.
  • The cost config fields on custom provider models have no observable effect.
  • The upstream API correctly returns token usage in the response body.

Environment

  • OpenCode version: latest (1.14.x)
  • OS: macOS
  • Provider: @ai-sdk/openai-compatible with Chinese model endpoints (GLM-5.2, DeepSeek V4 Pro, MiMo V2 Pro)

Impact

This affects all users using non-Anthropic/non-OpenAI providers — which is a massive user base in China and other regions. Many are resorting to third-party plugins (opencode-throughput with manual pricing configs) as workarounds.

PR #17645 already has a working fix with test coverage. Could the team prioritize reviewing it?

Reacted by Mel O'Hagan

Activity

  1. github-actions
    assigned
    nexxeln
    on Jul 2, 2026
  2. github-actions commented on Jul 2, 2026

    @github-actions
    github-actionsBot
    on Jul 2, 2026 – with GitHub Actions
    Contributor
    More actions

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

    • Cost tracking ($ Spent) does not work for custom provider models #17223: Cost tracking ($ Spent) does not work for custom provider models
    • Cost tracking shows $0.00 for custom providers using @ai-sdk/openai-compatible even when cost fields are configured #24113: Cost tracking shows $0.00 for custom providers using @ai-sdk/openai-compatible even when cost fields are configured (closed)
    • Token usage always shows 0 when using Zhipu Coding Plan API with @ai-sdk/openai-compatible #25986: Token usage always shows 0 when using Zhipu Coding Plan API with @ai-sdk/openai-compatible

    (Note: #24113 and #17223 are already referenced in the issue body, but #25986 in particular covers the same Zhipu/@ai-sdk/openai-compatible combination.)

  3. gabrielandujar commented on Aug 8, 2026

    @gabrielandujar
    gabrielandujar
    on Aug 8, 2026
    More actions

    Additional reproduction with native OpenAI provider:

    I reproduced this issue with a native OpenAI provider (not @ai-sdk/openai-compatible). When using GPT-5.6 via OpenCode's built-in OpenAI provider, token usage IS tracked correctly in the sidebar (tokens input/output update in real-time, context % updates).

    This confirms:

    1. OpenCode's token tracking pipeline works (plugin version 1.18.x)
    2. The issue is isolated to the @ai-sdk/openai-compatible adapter — it receives usage data from the provider but does not propagate it to OpenCode's internal tracking
    3. SQLite DB columns (tokens_input, tokens_output, cost) remain at 0 for all openai-compatible sessions

    Provider response verified independently — the underlying API returns usage correctly. The gap is in how OpenCode consumes usage from the openai-compatible adapter vs native providers.

  4. mohagan9 commented on Sep 30, 2026

    @mohagan9
    mohagan9
    on Sep 30, 2026
    More actions

    I am seeing the same issue for openai/gpt-6-luna. Note I selected it verbatim from the models list, as per my opencode.jsonc. (I did not use Luna latest from the list).

    Image Image

    I had spent at least $0.10 at the time of the screenshot

  5. opencodejr commented on Oct 29, 2026

    @opencodejr
    opencodejrBot
    on Oct 29, 2026
    Contributor
    More actions

    Thanks for the detailed report, and for linking the related work!

    This report is about OpenCode 1.14.x, which is v1. v1 now only gets fixes for critical bugs (data loss, security problems, or breakage with no workaround). A wrong cost display is unlikely to be fixed there. The earlier fix PRs (#17645, #36903) were closed for the same reason; maintainers asked for the fix to be ported to v2.

    Please try OpenCode v2 (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0). If cost still shows $0.00 on v2 with the same cost config, please reply here or open a new issue with your v2 version (opencode --version) and config. Also reply if you think this is critical for v1.

    Related issues:

    • Cost tracking shows $0.00 for custom providers using @ai-sdk/openai-compatible even when cost fields are configured #24113: the same problem reported on 1.14.22
    • Cost tracking ($ Spent) does not work for custom provider models #17223: the original report that custom-provider cost config has no effect
    • No usage/cost shown for DeepInfra provider (openai-compatible) #45483: no usage or cost shown for an @ai-sdk/openai-compatible provider (DeepInfra)
    • [FEATURE]: Display token usage information in the TUI #13003: request to show cost in the TUI
  6. opencodejr
    added
    pending close
    triaging
    on Oct 29, 2026
  7. opencodejr
    closed this as not plannedon Oct 30, 2026
  8. opencodejr commented on Oct 30, 2026

    @opencodejr
    opencodejrBot
    on Oct 30, 2026
    Contributor
    More actions

    We haven't heard back, so I'm closing this as not planned. The report is about OpenCode v1 (1.14.x), and v1 only gets critical fixes. The $0.00 cost display for @ai-sdk/openai-compatible providers doesn't meet that bar.

    If you still see $0.00 on OpenCode v2 with the same cost config, please open a new issue with your opencode --version output and config. The closest open report is #45483. Thanks again for the detailed write-up!

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

Metadata

Metadata

Assignees

  • @nexxeln
    nexxeln

Labels

pending closetriaging

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.