anomalyco / anomalyco/opencode

Feature Request: Add Zen balance API endpoint

Open
#10,448 7 comments 35 reactions 1 assignee View on GitHub

@fwang is already working on this.

Since Jan 24, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
Avg merge
7h 2m
Merged PRs (30d)
384

Description

Summary

Add a public API endpoint to query the current Zen account balance programmatically.

Use Case

I'd like to display my Zen balance in my system status bar (waybar on Linux). Currently, the only way to check balance is through the web dashboard, which makes automation impossible.

A simple endpoint like GET /zen/v1/balance (authenticated with the existing API key) would enable:

  • Status bar widgets showing remaining credits
  • Alerts when balance drops below a threshold
  • Integration with budgeting/monitoring tools
  • CI pipelines that check balance before expensive runs

Proposed API

GET https://opencode.ai/zen/v1/balance
Authorization: Bearer <api-key>

Response:
{
  "balance": 42.50,
  "currency": "USD",
  "auto_reload": {
    "enabled": true,
    "threshold": 5.00,
    "amount": 20.00
  }
}

Workaround

Currently using opencode stats to track local spending, but this doesn't reflect the actual account balance.

Additional Context

The auto-reload feature suggests the infrastructure to query balance already exists server-side. Exposing it via API would be a small addition with high utility for power users.

Thanks for building such a great tool! 🙏

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.