A unified CLI tool for monitoring costs and usage across multiple LLM platforms
- 🔑 Multiple Authentication: API Key, browser cookie, official SDK support
- 🌐 27 Platforms Supported: Official platforms (DeepSeek, Moonshot, Volcengine, Aliyun, Tencent, Zhipu, SiliconFlow, OpenAI, Anthropic, Google) + third-party relays (FoxCode, DuckCoding, PackyCode, 88Code, 88996, AICoding, YouAPI, CSMindAI, YesVg, Cubence, DawClaudeCode, Magic666, Jimiai) + relay platforms (OneAPI, APIProxy, FastGPT, MiniMax)
- 💰 Real-time Balance & Spent: Track both current balance and actual spending
- 📊 Flexible Output: Table, JSON, Markdown, and total-only formats
- 💱 Multi-Currency: Automatic conversion between CNY, USD, EUR, and more
- 🎯 Token Monitoring: Detailed token usage for supported platforms
- 🛡️ Fault Tolerant: Single platform failures won't break the entire tool
- ⚙️ Easy Configuration: Simple setup with environment variables
- 🔒 Independent Configuration: Special platforms use separate config files to avoid global pollution
- ⚡ High Performance: Multi-threaded concurrent checking (5 workers) for fast multi-platform queries
# Clone the repository
git clone <repository-url>
cd llm_balance
# Install dependencies (includes Volcengine SDK)
pip install -r requirements.txt
# Install CLI tool
pip install -e .
# Verify installation
llm-balance --help
llm-balance ratesChoose the platforms you want to use and configure their authentication:
# DeepSeek (API Key)
export DEEPSEEK_API_KEY="sk-your-deepseek-api-key"
# Moonshot (API Key)
export MOONSHOT_API_KEY="sk-your-moonshot-api-key"
# SiliconFlow (API Key)
export SILICONFLOW_API_KEY="your-siliconflow-api-key"# Volcengine (Official SDK)
export VOLCENGINE_ACCESS_KEY="your-volcengine-access-key"
export VOLCENGINE_SECRET_KEY="your-volcengine-secret-key"
# Aliyun (Official SDK)
export ALIYUN_ACCESS_KEY_ID="your-aliyun-access-key-id"
export ALIYUN_ACCESS_KEY_SECRET="your-aliyun-access-key-secret"
# Tencent Cloud (SDK)
export TENCENT_API_KEY="your-tencent-secret-id:your-tencent-secret-key"# Zhipu AI (Requires browser login)
# 1. Login to https://open.bigmodel.cn
# 2. Set global browser for cookie extraction
llm-balance set-browser chrome
# Or override per command: llm-balance cost --browser=chrome# DuckCoding (Requires independent configuration)
# Method 1: Environment variable
export DUCKCODING_API_USER_ID="your_user_id"
# Method 2: Separate config file
llm-balance platform_config duckcoding api_user_id your_user_id
# Method 3: Manual config file creation
cat > ~/.llm_balance/duckcoding_config.yaml << EOF
api_user_id: your_user_id
EOF
# Then login to https://duckcoding.com and run:
llm-balance cost --platform=duckcoding
# PackyCode (Requires independent configuration)
# Method 1: Environment variable
export PACKYCODE_API_USER_ID="your_user_id"
# Method 2: Separate config file
llm-balance platform_config packycode api_user_id your_user_id
# Method 3: Manual config file creation
cat > ~/.llm_balance/packycode_config.yaml << EOF
api_user_id: your_user_id
EOF
# Then login to https://packyapi.com and run:
llm-balance cost --platform=packycode
# CSMindAI (Requires independent configuration)
# Method 1: Environment variable
export CSMINDAI_API_USER_ID="your_user_id"
# Method 2: Separate config file
llm-balance platform_config csmindai api_user_id your_user_id
# Method 3: Manual config file creation
cat > ~/.llm_balance/csmindai_config.yaml << EOF
api_user_id: your_user_id
EOF
# Then login to https://api.csmindai.com and run:
llm-balance cost --platform=csmindai
# YouAPI (Requires independent configuration)
# Method 1: Environment variable
export YOUAPI_NEW_API_USER="your_user_id"
# Method 2: Separate config file
llm-balance platform_config yourapi api_user_id your_user_id
# Method 3: Manual config file creation
cat > ~/.llm_balance/youapi_config.yaml << EOF
api_user_id: your_user_id
EOF
# Then login to https://yourapi.cn and run:
llm-balance cost --platform=yourapi
# Cubence (Requires independent configuration)
# Method 1: Environment variable
export CUBENCE_TOKEN="your_token"
# Method 2: Separate config file
llm-balance platform_config cubence token "your_token"
# Method 3: Manual config file creation
cat > ~/.llm_balance/cubence_config.yaml << EOF
token: your_token
EOF
# Then run:
llm-balance cost --platform=cubence
# 88996.cloud (Requires independent configuration)
# Method 1: Environment variable
export CLOUD88996_API_USER_ID="your_user_id"
# Method 2: Manual config file creation
cat > ~/.llm_balance/88996_config.yaml << EOF
api_user_id: your_user_id
EOF
# Then login to https://88996.cloud and run:
llm-balance cost --platform=88996# Test a single platform (choose one you configured)
llm-balance cost --platform=deepseek
# Check all configured platforms
llm-balance cost
# View results in different formats
llm-balance cost --format=table # Clean console output
llm-balance cost --format=json # Machine-readable
llm-balance cost --format=total # Just the totalsIf you encounter issues, try these steps:
# Check if environment variables are set
echo $DEEPSEEK_API_KEY
echo $VOLCENGINE_ACCESS_KEY
# Test individual platform with debug output
llm-balance cost --platform=deepseek --format=json
# Verify configuration
llm-balance list
# Check browser setting for cookie-based platforms
llm-balance set-browser chrome
# Test network connectivity
curl -I https://api.deepseek.comCommon Issues:
- API Key not found: Make sure environment variables are set correctly
- Browser authentication failed: Ensure you're logged into the platform website
- Permission denied: Check API key permissions and account status
- Network timeout: Verify internet connection and platform API status
# Check all configured platforms
llm-balance cost
# Check specific platform
llm-balance cost --platform=deepseek
# Multiple platforms (comma-separated)
llm-balance cost --platform=volcengine,aliyun
# Browser override for cookie-based platforms
llm-balance cost --platform=zhipu --browser=chrome
# Output formats
llm-balance cost --format=table # Clean console view (default)
llm-balance cost --format=json # Machine-readable
llm-balance cost --format=total # Just the totals
# Currency conversion
llm-balance cost --currency=USD # Convert to USD
llm-balance cost --currency=EUR # Convert to EUR💡 New Feature: The cost command now displays both current balance and spent amount for all platforms, providing a complete financial overview of your LLM usage.
# Check token usage for supported platforms
llm-balance package
# Specific platform and model
llm-balance package --platform=volcengine --model=deepseek-r1
# Multiple platforms
llm-balance package --platform=volcengine,zhipu
# Different output formats
llm-balance package --format=table # Console view
llm-balance package --format=json # Machine-readable
llm-balance package --show-all # Include inactive entries
# Show subscription lifecycle information (for 88code, FoxCode, Moonshot)
llm-balance package --show-expiry # Show expiry dates
llm-balance package --show-reset # Show reset counts
llm-balance package --show-reset-time # Show reset times
llm-balance package --show-expiry --show-reset --show-reset-time # Show allNote: Token monitoring is available for Volcengine, Zhipu, DuckCoding, CSMindAI, YouAPI, 88Code, 88996, DawClaudeCode, Magic666, Jimiai, FoxCode, and Moonshot platforms
Subscription Features: For platforms with subscription-based billing (88Code, FoxCode), the tool automatically distinguishes between:
- Pay-per-use packages: Calculated by actual usage
- Subscription packages: Calculated by time depreciation with reset information
By default the
packagecommand hides entries marked as inactive. Pass--show-allto include them across all output formats.
Check coding plan limits for Claude Code compatible platforms (Volcengine, Zhipu, ChatGPT):
# Check all platforms
llm-balance plan
# Check specific platform
llm-balance plan --platform=volcengine
llm-balance plan --platform=chatgpt
# Use specific browser for cookies
llm-balance plan --browser=doubaoNote: Coding Plan monitoring requires platform-specific authentication:
- Volcengine: Browser cookies (login to console.volcengine.com)
- Zhipu AI: Set
ZHIPU_AUTH_TOKENorANTHROPIC_AUTH_TOKENenvironment variable- ChatGPT: Read local
~/.codex/sessions/**/rollout-*.jsonllogs generated by Codex CLI sessions (codexalias supported)- ChatGPT Review Quota: If review has dedicated limits in logs, show
review_session/review_weekly; otherwise fallback to ChatGPT main quota when review activity exists
| Command | Purpose | Example |
|---|---|---|
llm-balance cost |
Check balance & spent | llm-balance cost --platform=volcengine |
llm-balance package |
Check token usage | llm-balance package --platform=zhipu |
llm-balance plan |
Check coding plan limits | llm-balance plan --platform=volcengine |
llm-balance list |
List platforms | llm-balance list |
llm-balance enable |
Enable platform | llm-balance enable deepseek |
llm-balance disable |
Disable platform | llm-balance disable tencent |
# List all platforms and their status
llm-balance list
# Enable platform
llm-balance enable moonshot
# Disable platform
llm-balance disable moonshot
# Switch authentication method (SDK vs Cookie)
llm-balance config volcengine auth_type sdk # Use official SDK
llm-balance config volcengine auth_type cookie # Use browser cookies
# Independent configuration for special platforms
llm-balance platform_config duckcoding # View DuckCoding config
llm-balance platform_config duckcoding api_user_id your_user_id # Set user ID# View complete platform configuration
llm-balance config deepseek
# View specific configuration item
llm-balance config deepseek api_url
# Set configuration item (supports automatic type conversion)
llm-balance config deepseek enabled true
llm-balance config deepseek timeout 30# View total balance in USD for all platforms
llm-balance cost --currency=USD --format=total
# Get detailed EUR balance for specific platform
llm-balance cost --platform=deepseek --currency=EUR --format=table
# Check multiple platforms at once
llm-balance cost --platform=volcengine,aliyun,deepseek --format=table
llm-balance cost --platform="openai, deepseek, moonshot" --currency=USD --format=total
# Use custom exchange rates and output as JSON
LLM_BALANCE_RATES='{"USD": 7.5}' llm-balance cost --currency=USD --format=json
# Combine multiple parameters
llm-balance cost --platform=openai --browser=chrome --currency=GBP --format=markdown
# Test Volcengine SDK authentication
export VOLCENGINE_ACCESS_KEY="your_access_key"
export VOLCENGINE_SECRET_KEY="your_secret_key"
llm-balance cost --platform=volcengine --format=table
# Test Chinese platforms
export TENCENT_API_KEY="your_tencent_api_key"
llm-balance cost --platform=tencent --format=table
# Test cookie authentication platforms
# Zhipu requires login to open.bigmodel.cn
llm-balance cost --platform=zhipu --browser=chrome# Check token usage across all supported platforms
llm-balance package
# Check token usage for specific model on Volcengine
llm-balance package --platform=volcengine --model=deepseek-r1
# Check token usage for Zhipu AI with specific model
llm-balance package --platform=zhipu --model=glm-4-plus
# Compare token usage across multiple platforms
llm-balance package --platform=volcengine,zhipu --format=table
# Get detailed JSON output for token usage
llm-balance package --platform=volcengine --format=json
# Filter models by partial name matching
llm-balance package --platform=volcengine --model=deepseek
llm-balance package --platform=zhipu --model=glm-4
# Check token usage in different currencies
llm-balance package --currency=USD --format=tableSupports automatic exchange rate conversion to convert balances in different currencies to a target currency for total calculation. Supports multiple currency types including CNY, USD, EUR, etc.
System includes following default rates (relative to CNY):
- CNY: 1.0
- USD: 7.2
- EUR: 7.8
- GBP: 9.1
- JPY: 0.048
- KRW: 0.0054
- Points: 0.01
# View current exchange rates
llm-balance rates
# Custom exchange rates (session level)
LLM_BALANCE_RATES='{"USD": 7.5}' llm-balance cost
# Set multiple exchange rates
LLM_BALANCE_RATES='{"USD": 7.5, "EUR": 8.0}' llm-balance cost- Flexible Conversion: Supports conversion between any currencies
- Total Display: Table and total formats show totals in specified currency
- Original Data: JSON and Markdown formats preserve original currency display
- Default Currency: Uses CNY as default output currency
- Custom Rates: Set via
LLM_BALANCE_RATESenvironment variable
- CNY (Chinese Yuan)
- USD (US Dollar)
- EUR (Euro)
- GBP (British Pound)
- JPY (Japanese Yen)
- KRW (Korean Won)
- Points (Points)
Configuration file is located at ~/.llm_balance/platforms.yaml, automatically created on first run:
# Global browser configuration for all cookie-based platforms
browser: chrome
platforms:
deepseek:
api_url: "https://api.deepseek.com/user/balance"
method: "GET"
auth_type: "bearer_token"
env_var: "DEEPSEEK_API_KEY"
balance_path: ["balance_infos", "0", "total_balance"]
currency_path: ["balance_infos", "0", "currency"]
enabled: true
headers:
User-Agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36"
Accept: "application/json"
openai:
api_url: "https://api.openai.com/v1/organization/costs"
method: "GET"
auth_type: "bearer_token"
env_var: "OPENAI_ADMIN_KEY"
balance_path: ["data", "0", "results", "0", "amount", "value"]
currency_path: ["data", "0", "results", "0", "amount", "currency"]
enabled: true
params:
start_time: 1730419200
limit: 1| Platform | Authentication | Status | Description | Token Usage | Spent Tracking |
|---|---|---|---|---|---|
| OpenAI | Admin API | ✅ | Requires OPENAI_ADMIN_KEY | ❌ Not Available | ✅ Full Support |
| Anthropic | Admin API | ✅ | Requires ANTHROPIC_ADMIN_KEY | ❌ Not Available | ✅ Full Support |
| API Key | ✅ | Requires GOOGLE_API_KEY | ❌ Not Available | ✅ Full Support |
| Platform | Authentication | Status | Description | Token Usage | Spent Tracking |
|---|---|---|---|---|---|
| DeepSeek | API Key | ✅ | Requires DEEPSEEK_API_KEY | ❌ Not Available | ❌ Not Supported |
| Moonshot | API Key | ✅ | Requires MOONSHOT_API_KEY | ❌ Not Available | ❌ Not Supported |
| Volcengine | SDK/Cookie | ✅ | Requires VOLCENGINE_ACCESS_KEY + SECRET_KEY or browser login | ✅ Full Support | ✅ Full Support |
| Aliyun | Official SDK | ✅ | Requires ALIYUN_ACCESS_KEY_ID + SECRET_KEY | ❌ Not Available | ✅ Full Support |
| Tencent | SDK | ✅ | Requires TENCENT_API_KEY (SecretId:SecretKey) | ❌ Not Available | ✅ Available |
| Zhipu | Cookie | ✅ | Requires login to https://open.bigmodel.cn | ✅ Full Support | ✅ Full Support |
| SiliconFlow | API Key | ✅ | Requires SILICONFLOW_API_KEY | ❌ Not Available | ✅ Full Support |
| Platform | Authentication | Status | Description | Token Usage | Spent Tracking | Independent Config |
|---|---|---|---|---|---|---|
| FoxCode | Cookie | ✅ | Relay service with dashboard access | ✅ Full Support | ✅ Full Support | ❌ No |
| DuckCoding | Cookie | ✅ | Relay service with token packages | ✅ Full Support | ✅ Full Support | ✅ Yes |
| 88Code | Console Token | ✅ | Relay service with subscription packages | ✅ Full Support | ✅ Full Support | ✅ Yes |
| 88996.cloud | Cookie | ✅ | Relay service with quota system | ✅ Full Support | ✅ Full Support | ✅ Yes |
| DawClaudeCode | Cookie | ✅ | Relay service with quota system | ✅ Full Support | ✅ Full Support | ✅ Yes |
| Magic666 | Cookie | ✅ | Relay service with quota system | ✅ Full Support | ✅ Full Support | ✅ Yes |
| Jimiai | Cookie | ✅ | Relay service with quota system | ✅ Full Support | ✅ Full Support | ✅ Yes |
| AICoding | Cookie | ✅ | Relay service with credits system | ✅ Full Support | ❌ Not Available | ❌ No |
| YourAPI | Cookie | ✅ | Relay service with quota system | ✅ Full Support | ✅ Full Support | ✅ Yes |
Production-Ready (17 platforms): All platforms listed above are fully tested and ready for production use.
Independent Configuration: DuckCoding, 88Code, 88996, DawClaudeCode, Magic666, Jimiai, and YourAPI use separate configuration files to avoid polluting global settings.
Development Status: Additional platforms (Azure OpenAI, Lingyi, MiniMax) are available in the dev branch and under active development.
Some platforms provide token usage monitoring capabilities:
| Platform | Token Usage Support | Models Available |
|---|---|---|
| Volcengine | ✅ Full Support | deepseek-r1, deepseek-v3, doubao-pro-32k, doubao-pro-128k, etc. |
| Zhipu AI | ✅ Full Support | glm-4-plus, glm-4, glm-3-turbo, cogview-3, etc. |
| DeepSeek | ❌ Not Available | - |
| Moonshot | ❌ Not Available | - |
| Aliyun | ❌ Not Available | - |
| Tencent | ❌ Not Available | - |
| SiliconFlow | ❌ Not Available | - |
Real-time spent amount tracking across supported platforms:
| Platform | Spent Tracking | Data Source | Accuracy |
|---|---|---|---|
| Volcengine | ✅ Full Support | Official API | High |
| Aliyun | ✅ Full Support | BSS Transaction API | High |
| Zhipu AI | ✅ Full Support | Billing API | High |
| Tencent Cloud | ✅ Available | Billing API | Medium |
| SiliconFlow | ✅ Full Support | Billing API | High |
| DeepSeek | ❌ Not Supported | N/A | N/A |
| Moonshot | ❌ Not Supported | N/A | N/A |
Note: Platforms marked as "Not Supported" for spent tracking will display "-" instead of a numeric value to clearly distinguish between unsupported functionality and zero spending.
For platforms providing API interfaces:
# DeepSeek
export DEEPSEEK_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxx"
# OpenAI (currently not supported for balance queries)
# export OPENAI_ADMIN_KEY="sk-admin-xxxxxxxxxxxxxxxxxxxxxxxx"
# Aliyun (requires both access key ID and secret)
export ALIYUN_ACCESS_KEY_ID="your_access_key_id"
export ALIYUN_ACCESS_KEY_SECRET="your_access_key_secret"
# Moonshot
export MOONSHOT_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxx"
# SiliconFlow
export SILICONFLOW_API_KEY="your_siliconflow_api_key"For platforms requiring browser sessions:
- Login to the corresponding platform website
- Tool automatically retrieves authentication cookies from browser
- Supports Chrome, Firefox, Arc, Brave and other mainstream browsers
Some platforms use special access methods:
- Zhipu uses cookie authentication via browser login
- Requires login to https://open.bigmodel.cn
FoxCode is a cookie-authenticated relay with dashboard-based package and cost information.
- Auth: Browser cookie on
foxcode.rjj.cc. Readauth_tokenand queryhttps://foxcode.rjj.cc/api/user/dashboardwithAuthorization: Bearer <token>. - package: Uses
data.subscription.activeentries.- Total = plan
quotaLimit - Remaining =
quotaRemaining(fallback to planduration) - Used = Total - Remaining
- Package column shows
plan.name
- Total = plan
- cost: Balance is shown as
-(no top-up on this relay); Spent = sum ofdata.subscription.history[*].plan.pricein CNY.
Examples:
llm-balance package --platform=foxcode
llm-balance cost --platform=foxcode
# Specify browser if needed
llm-balance package --platform=foxcode --browser=chrome
llm-balance cost --platform=foxcode --browser=chromeDuckCoding is a cookie-authenticated relay with token-based package and cost information, using independent configuration.
- Auth: Browser cookie on
duckcoding.com. Queryhttps://duckcoding.com/api/user/selfwithnew-api-userheader. - Configuration: Requires
api_user_idsetting via environment variable or separate config file. - package: Uses
data.quotaanddata.used_quotafrom user info.- Total =
quota(in tokens) - Used =
used_quota(in tokens) - Remaining = Total - Used
- Package column shows "DuckCoding 按量计费(不到期)"
- Total =
- cost: Balance and spent calculated from quota data.
- Balance =
quota / 500000(in CNY) - Spent =
used_quota / 500000(in CNY)
- Balance =
Configuration Options:
# Method 1: Environment variable
export DUCKCODING_API_USER_ID="your_user_id"
# Method 2: CLI command
llm-balance platform_config duckcoding api_user_id your_user_id
# Method 3: Manual config file
cat > ~/.llm_balance/duckcoding_config.yaml << EOF
api_user_id: your_user_id
EOFExamples:
# Check balance and spent
llm-balance cost --platform=duckcoding
# Check token usage
llm-balance package --platform=duckcoding
# View configuration
llm-balance platform_config duckcoding
# Configure user ID
llm-balance platform_config duckcoding api_user_id your_user_id88Code is a console token-authenticated relay with subscription-based packages and cost information.
- Auth: Console token via environment variable or separate config file.
- Configuration: Requires
console_tokensetting. - package: Uses subscription data from
https://www.88code.org/admin-api/cc-admin/system/subscription/my.- Total = sum of all subscription costs (active + inactive)
- Balance = calculated based on usage ratio of active subscriptions
- Spent = Total cost - Balance
- Package column shows subscription features with status display
- Status: Shows "active" or "inactive" based on subscription
isActiveflag
Configuration Options:
# Method 1: Environment variable
export CODE88_CONSOLE_TOKEN="your_console_token"
# Method 2: Manual config file
cat > ~/.llm_balance/88code_config.yaml << EOF
console_token: your_console_token
EOFExamples:
# Check balance and spent
llm-balance cost --platform=88code
# Check token usage with status display
llm-balance package --platform=88codeYourAPI is a cookie-authenticated relay with simple quota-based balance and spent calculation.
- Auth: Browser cookie on
yourapi.cnwithnew-api-userheader. - Configuration: Requires
api_user_idsetting via environment variable or separate config file. - package: Uses quota data from
https://yourapi.cn/api/user/self.- Total =
quota(in tokens, converted to CNY by dividing by 500000) - Used =
used_quota(in tokens, converted to CNY by dividing by 500000) - Remaining = Total - Used
- Package column shows user group information
- Status: Shows "active" or "inactive" based on user status
- Total =
- cost: Balance and spent calculated from quota data with currency conversion.
Configuration Options:
# Method 1: Environment variable
export YOURAPI_NEW_API_USER="your_user_id"
# Method 2: Manual config file
cat > ~/.llm_balance/yourapi_config.yaml << EOF
api_user_id: "your_user_id"
EOFExamples:
# Check balance and spent
llm-balance cost --platform=yourapi
# Check token usage
llm-balance package --platform=yourapi
# View configuration
llm-balance platform_config yourapi88996.cloud is a cookie-authenticated relay with quota-based balance and package information.
- Auth: Browser cookie on
88996.cloudwithrix-api-userheader. - Configuration: Requires
api_user_idsetting via environment variable or separate config file. - package: Uses quota data from
https://88996.cloud/api/user/self.- Total =
quota + bonus_quota(in tokens) - Used =
used_quota(in tokens) - Remaining = Total - Used
- Total =
- cost: Balance and spent calculated from quota data.
- Balance =
(quota + bonus_quota) / 500000(in CNY) - Spent =
used_quota / 500000(in CNY)
- Balance =
Configuration Options:
# Method 1: Environment variable
export CLOUD88996_API_USER_ID="your_user_id"
# Method 2: Manual config file
cat > ~/.llm_balance/88996_config.yaml << EOF
api_user_id: "your_user_id"
EOFExamples:
# Check balance and spent
llm-balance cost --platform=88996
# Check token usage
llm-balance package --platform=88996DawClaudeCode is a cookie-authenticated relay with quota-based balance and package information.
- Auth: Browser cookie on
dawclaudecode.comwithnew-api-userheader. - Configuration: Requires
api_user_idsetting via environment variable or separate config file. - package: Uses quota data from
https://dawclaudecode.com/api/user/self.- Total =
quota + bonus_quota(in tokens) - Used =
used_quota(in tokens) - Remaining = Total - Used
- Total =
- cost: Balance and spent calculated from quota data.
- Balance =
(quota + bonus_quota) / 500000(in CNY) - Spent =
used_quota / 500000(in CNY)
- Balance =
Configuration Options:
# Method 1: Environment variable
export DAWCLAUDECODE_API_USER_ID="your_user_id"
# Method 2: Manual config file
cat > ~/.llm_balance/dawclaudecode_config.yaml << EOF
api_user_id: "your_user_id"
EOFExamples:
# Check balance and spent
llm-balance cost --platform=dawclaudecode
# Check token usage
llm-balance package --platform=dawclaudecodeMagic666 is a cookie-authenticated relay with quota-based balance and package information.
- Auth: Browser cookie on
magic666.topwithnew-api-userheader. - Configuration: Requires
api_user_idsetting via environment variable or separate config file. - package: Uses quota data from
https://magic666.top/api/user/self.- Total =
quota + bonus_quota(in tokens) - Used =
used_quota(in tokens) - Remaining = Total - Used
- Total =
- cost: Balance and spent calculated from quota data.
- Balance =
(quota + bonus_quota) / 500000(in CNY) - Spent =
used_quota / 500000(in CNY)
- Balance =
Configuration Options:
# Method 1: Environment variable
export MAGIC666_API_USER_ID="your_user_id"
# Method 2: Manual config file
cat > ~/.llm_balance/magic666_config.yaml << EOF
api_user_id: "your_user_id"
EOFExamples:
# Check balance and spent
llm-balance cost --platform=magic666
# Check token usage
llm-balance package --platform=magic666Jimiai is a cookie-authenticated relay with quota-based balance and package information.
- Auth: Browser cookie on
jimiai.aiwithnew-api-userheader. - Configuration: Requires
api_user_idsetting via environment variable or separate config file. - package: Uses quota data from
https://jimiai.ai/api/user/self.- Total =
quota(in tokens) - Used =
used_quota(in tokens) - Remaining = Total - Used
- Total =
- cost: Balance and spent calculated from quota data.
- Balance =
quota / 500000(in CNY) - Spent =
used_quota / 500000(in CNY)
- Balance =
Configuration Options:
# Method 1: Environment variable
export JIIMIAI_API_USER_ID="your_user_id"
# Method 2: Manual config file
cat > ~/.llm_balance/jimiai_config.yaml << EOF
api_user_id: "your_user_id"
EOFExamples:
# Check balance and spent
llm-balance cost --platform=jimiai
# Check token usage
llm-balance package --platform=jimiaiAICoding is a cookie-authenticated relay with credits-based balance information.
- Auth: Browser cookie on
aicoding.sh. - package: Uses credits data from
https://aicoding.sh/api/user-credits/permanent.- Total =
personal_credits(in credits) - Remaining =
personal_credits(in credits)
- Total =
- cost: Balance calculated from credits data.
- Balance =
personal_credits / 100(in CNY) - Spent = Not available (returns "-")
- Balance =
Examples:
# Login to https://aicoding.sh first, then:
# Check balance
llm-balance cost --platform=aicoding
# Check credits usage
llm-balance package --platform=aicodingAll cookie-based platforms use a single global browser configuration:
# Set global browser (affects all cookie platforms)
llm-balance set-browser chrome
llm-balance set-browser firefox
llm-balance set-browser arc- Chrome (Recommended)
- Firefox
- Arc
- Brave
- Chromium
Q: Cookie Authentication Failed
# Ensure you're logged in to the corresponding platform
# Check global browser setting
llm-balance set-browser chrome
# Or override for single command
llm-balance cost --browser=chromeQ: Invalid API Key
# Check if environment variables are set
echo $DEEPSEEK_API_KEY
echo $OPENAI_ADMIN_KEY
# Reset environment variables
export DEEPSEEK_API_KEY="your_valid_api_key"Q: Specific Platform Timeout
# Test problematic platform individually
llm-balance cost --platform=deepseek
# Check network connection
curl -I https://api.deepseek.com- Main configuration:
~/.llm_balance/platforms.yaml - Customizable via
LLM_BALANCE_CONFIG_FILEenvironment variable
- 🔒 Local Processing: All authentication information is processed locally, not uploaded to external servers
- 🍪 Cookie Reading: Only reads necessary authentication cookies from browser, doesn't get other sensitive information
- 🛡️ Environment Variables: API keys managed via environment variables, not written to configuration files
- 🔄 Session Nature: Cookie authentication has时效性, requires regular platform re-login
src/llm_balance/
├── __init__.py # Package info and version
├── cli.py # CLI command interface
├── balance_checker.py # Main business logic
├── config.py # Configuration file management
├── platform_configs.py # Platform configuration management
├── error_handler.py # Error handling
├── utils.py # Utility functions
├── token_checker.py # Token usage monitoring
├── token_formatter.py # Token output formatting
└── platform_handlers/ # Platform handlers
├── __init__.py # Handler factory
├── base.py # Base handler class
├── aliyun.py # Aliyun handler ✅
├── deepseek.py # DeepSeek handler ✅
├── moonshot.py # Moonshot handler ✅
├── volcengine.py # Volcengine handler ✅
├── tencent.py # Tencent handler ✅
├── zhipu.py # Zhipu handler ✅
├── siliconflow.py # SiliconFlow handler ✅
├── openai.py # OpenAI handler ✅
├── anthropic.py # Anthropic handler ✅
├── google.py # Google handler ✅
├── foxcode.py # FoxCode relay handler ✅
├── duckcoding.py # DuckCoding relay handler ✅
├── _88code.py # 88Code relay handler ✅
├── _88996.py # 88996.cloud relay handler ✅
├── aicoding.py # AICoding relay handler ✅
└── yourapi.py # YourAPI relay handler ✅
Note: Additional platform handlers (Azure OpenAI, Lingyi, MiniMax) are available in the dev branch.
- Configure Platform: Add new platform configuration in
~/.llm_balance/platforms.yaml - Create Handler: Inherit from
BasePlatformHandlerclass, implement necessary authentication and parsing logic - Register Handler: Add new platform in
create_handlerfunction inplatform_handlers/__init__.py - Test Verification: Test with
llm-balance cost --platform=<new_platform>
# Install development dependencies
pip install -e .
# Run tests
llm-balance cost --format=json
# Debug specific platform
llm-balance cost --platform=deepseek --browser=chromeIssues and Pull Requests are welcome!
- Fork this repository
- Create feature branch (
git checkout -b feature/new-platform) - Commit changes (
git commit -am 'Add new platform support') - Push to branch (
git push origin feature/new-platform) - Create Pull Request
MIT License - See LICENSE file for details