一键查询当前 AI 服务的账户余额,支持 14 个主流 AI 提供商
Project description
check-balance
One-click balance checker for your AI API services. Supports 14 mainstream AI providers with automatic detection. Works as an MCP server or standalone CLI.
Features
- MCP Server — Integrates with opencode, Claude Code, Cursor, Claude Desktop
- CLI Tool — Run
check-balancein any terminal - Auto-detection — Reads opencode config and environment variables
- 14 Providers — China (¥) and International ($) regions
- Cross-platform — Linux, macOS, Windows (WSL supported)
- Zero config — Just set your API keys and go
Supported Providers
China Region (¥)
| Provider | API Key Env | Balance API | Status |
|---|---|---|---|
| DeepSeek | DEEPSEEK_API_KEY |
GET /user/balance |
✅ Direct query |
| Moonshot / Kimi | MOONSHOT_API_KEY |
GET /v1/users/me/balance |
✅ Direct query |
| MiniMax | MINIMAX_API_KEY |
GET /v1/token_plan/remains |
✅ Direct query |
| StepFun | STEP_API_KEY |
GET /v1/accounts |
✅ Direct query |
| Zhipu / GLM | ZHIPU_API_KEY |
Quota API | ~ Quota info |
| DashScope / Qwen | DASHSCOPE_API_KEY |
— | ⚠️ Console only |
| Baichuan | BAICHUAN_API_KEY |
— | ⚠️ Console only |
International Region ($)
| Provider | API Key Env | Balance API | Status |
|---|---|---|---|
| OpenAI | OPENAI_API_KEY |
Usage/Cost API | ~ Usage + cost |
| Anthropic / Claude | ANTHROPIC_API_KEY |
Admin Key Cost API | ~ Usage + cost |
| xAI / Grok | XAI_API_KEY |
Balance API | ✅ Direct query |
| Together AI | TOGETHER_API_KEY |
Usage API | ~ Usage + cost |
| Mistral | MISTRAL_API_KEY |
— | ⚠️ Console only |
| Groq | GROQ_API_KEY |
— | ⚠️ Console only |
| Cohere | COHERE_API_KEY |
— | ⚠️ Console only |
Note: Cursor subscription balance is not supported as Cursor uses its own proxy and does not expose API keys.
Installation
pip install check-balance
Usage
As CLI
check-balance
# or
python -m check_balance
As MCP Server
opencode
Add to your opencode.json:
{
"mcp": {
"check-balance": {
"type": "local",
"command": ["python", "-m", "check_balance.mcp_server"],
"enabled": true
}
}
}
Then type /balance in opencode or ask "check my AI balance".
Claude Code
Create .mcp.json in your project root:
{
"mcpServers": {
"check-balance": {
"command": "python",
"args": ["-m", "check_balance.mcp_server"]
}
}
}
Or add to ~/.claude/mcp.json for global access.
Cursor
Create .cursor/mcp.json in your project root:
{
"mcpServers": {
"check-balance": {
"command": "python",
"args": ["-m", "check_balance.mcp_server"]
}
}
}
Or add to ~/.cursor/mcp.json for global access.
Claude Desktop
Edit claude_desktop_config.json:
| OS | Path |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
| Linux | ~/.config/Claude/claude_desktop_config.json |
{
"mcpServers": {
"check-balance": {
"command": "python",
"args": ["-m", "check_balance.mcp_server"]
}
}
}
How It Works
- Auto-detection — Reads
opencode.jsonto identify your current model/provider, then scans environment variables for all configured API keys - Balance query — Calls each provider's balance/usage API
- Formatted output — Shows results with ¥ (China) or $ (International) currency
Output Example
AI 服务余额查询
==================================================
* DeepSeek (中国)
余额: ¥ 142.50
Moonshot (中国)
余额: ¥ 3.00
OpenAI (海外)
OpenAI 未开放余额查询 API,近 30 天用量: $ 18.32
控制台: https://platform.openai.com/usage
Mistral (海外)
未开放余额查询 API
控制台: https://console.mistral.ai/usage
* 标记为当前使用的服务
Development
git clone https://github.com/hanmumuHL/check_balance.git
cd check_balance
pip install -e ".[dev]"
pytest
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file check_balance-0.1.0.tar.gz.
File metadata
- Download URL: check_balance-0.1.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63f7069689b8bf683cf60c075fdbd07f015cefd07f0082b5e1c09766b95d9167
|
|
| MD5 |
0d4a7dd44c484874d4ebc3c8dd864127
|
|
| BLAKE2b-256 |
57551c7f6ebbfd8ce10ee2cceea2c4926280ed8382559c24ba386e3f2517140a
|
File details
Details for the file check_balance-0.1.0-py3-none-any.whl.
File metadata
- Download URL: check_balance-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00719ee26464a5febe4f00c2fb35b808c0294d71a63ebb90223443cb93585772
|
|
| MD5 |
e1d56ad2680ea98e03b995ccc8152a7a
|
|
| BLAKE2b-256 |
76519076ca4f3601b31e8c5c611e49e6e5ddf64fab89e875355901a4ec98eeeb
|