# See your WanAPIs balance in Claude Code and CC Switch

> Keep your WanAPIs balance in view without opening the console: an open-source Claude Code status bar plugin shows it automatically, and CC Switch needs one pasted script. All you need is the sk- key you already use. You can also call the OpenAI-compatible balance endpoint directly.

Web page: https://wanapi.ai/docs/balance

WanAPIs supports the OpenAI-compatible balance endpoint used by new-api / one-api gateways (/v1/dashboard/billing/subscription). It works with your regular sk- API key — no separate access token needed. Many Claude Code and Codex companion tools read this endpoint, so once set up your balance stays visible where you work. Checking it doesn't call a model and costs nothing, and the number matches the Wallet page in the console.

## Setup steps

### 1. Check it once from the terminal

Replace sk-xxx with your key and run the command below. balance is what you have left; hard_limit_usd is your total credit so far (used + remaining).

**Terminal**

```
curl https://api.wanapis.com/v1/dashboard/billing/subscription \
  -H "Authorization: Bearer sk-xxx"

# Example response
{"object":"billing_subscription","has_payment_method":true,"soft_limit_usd":125.5,"hard_limit_usd":125.5,"system_hard_limit_usd":125.5,"access_until":0,"balance":23.8}
```

### 2. Claude Code: install a status bar plugin

The open-source claude-statusbar plugin (GitHub: leeguooooo/claude-code-usage-bar, MIT) uses the ANTHROPIC_BASE_URL and key you already set for Claude Code, finds the balance endpoint on its own and shows your remaining balance in the status bar, refreshing every 5 minutes. No extra configuration — restart Claude Code after installing.

**Install (needs Python; uv tool install or pipx install also work)**

```
pip install claude-statusbar
cs --setup
```

### 3. CC Switch: paste a script into Usage Query

Works for both Claude Code and Codex providers. Hover over your WanAPIs provider card, click Usage Query (📊 icon) → turn on Enable usage query → choose the Custom template → paste the script below → click Test script, and save once you see your balance. {{apiKey}} is filled in with the key from that provider automatically. An auto query interval of 5 minutes is a good default.

**CC Switch → Usage Query → Custom**

```
({
  request: {
    url: "https://api.wanapis.com/v1/dashboard/billing/subscription",
    method: "GET",
    headers: {
      "Authorization": "Bearer {{apiKey}}",
      "User-Agent": "cc-switch/1.0"
    }
  },
  extractor: function (response) {
    if (response.error) {
      return { isValid: false, invalidMessage: response.error.message };
    }
    return {
      remaining: response.balance,
      used: response.hard_limit_usd - response.balance,
      total: response.hard_limit_usd,
      unit: "USD"
    };
  }
})
```

## FAQ

### Is this my account balance or the key's own limit?

Keys are created without a spending limit by default, so you see your account balance. If you set a limit on a key in the console, you see what's left on that key instead — so sharing a key never reveals your whole account balance.

### Does checking the balance cost anything?

No. The balance endpoint doesn't call any model and is free.

### My tool isn't listed here. Will it work?

Any tool that supports the new-api / one-api balance endpoints (/v1/dashboard/billing/subscription and /v1/dashboard/billing/usage) works: balance = hard_limit_usd - total_usage / 100, or just read balance. If you write your own script, send a User-Agent header — Python urllib's default User-Agent gets blocked (403).

### Where can I see what each request cost?

The balance endpoint only returns totals. Per-model, per-request details are on the Usage Logs page in the console, where you can filter by key and model.

---

Generated by the WanAPIs website and kept in sync with the web page. All guides in Markdown: https://wanapi.ai/docs/index.md
