A collection of tools for interacting with DeepSeek API, starting with a Python CLI tool to check account balances and view available models.
- ✅ Check account balance - Total, topped-up, and granted balance
- ✅ View available models - List of models available in the API
- ✅ Multiple auth methods - Environment variables or command-line tokens
- ✅ JSON output - Perfect for scripting and automation
- ✅ API health checks - Verify your API token works
- ✅ Modern packaging - Works with both
pipanduv - ✅ Type hints - Full type annotations for better IDE support
- ✅ Comprehensive tests - Well-tested with pytest
- ✅ GitHub Actions - Automated releases to PyPI
# Install from PyPI
pip install dsbc
# Install with development dependencies
pip install dsbc[dev]
# Install with uv support
pip install dsbc[uv]# Install from PyPI
uv pip install dsbc
# Install with development dependencies
uv pip install "dsbc[dev]"# Clone the repository
git clone https://github.com/ianmerlos/dsbc.git
cd dsbc/cli
# Install with pip in development mode
pip install -e .
# Or install with uv
uv pip install -e .# Set your API token as environment variable
export DEEPSEEK_API_TOKEN="your-api-token-here"
# Also DEEKSEEK_API_KEY, DEEPSEEK_TOKEN, OPENAI_API_KEY
# Check your balance
dsbc
# Show available models
dsbc --models
# JSON output for scripting
dsbc --json
# Check API health
dsbc --health
# Verbose mode
dsbc --verbose# Show help
dsbc --help
# Check balance with specific token
dsbc --token sk-abc123def456
# Show models and balance
dsbc --models --verbose
# Output in JSON format
dsbc --json
# Check if API is accessible
dsbc --healthThe tool checks for API tokens in this order of priority:
--tokencommand-line argumentDEEPSEEK_API_TOKENenvironment variable (default)DEEPSEEK_TOKENenvironment variableDEEPSEEK_API_KEYenvironment variableOPENAI_API_KEYenvironment variable (for compatibility)
# Set default environment variable
export DEEPSEEK_API_TOKEN="sk-abc123def456"
# Or use a different variable
export DEEPSEEK_TOKEN="sk-xyz789uvw012"$ dsbc
==================================================
DEEPSEEK ACCOUNT BALANCE
==================================================
Status: ✅ Available
Currency: USD
Total Balance: 18.87 USD
Topped-up Balance: 18.87 USD
Granted Balance: 0.00 USD
==================================================$ dsbc --models
==================================================
DEEPSEEK AVAILABLE MODELS
==================================================
- deepseek-chat (owned by: deepseek)
- deepseek-reasoner (owned by: deepseek)
==================================================$ dsbc --json
{
"is_available": true,
"balance_infos": [
{
"currency": "USD",
"total_balance": "18.87",
"granted_balance": "0.00",
"topped_up_balance": "18.87"
}
]
}$ dsbc --models --json
{
"object": "list",
"data": [
{
"id": "deepseek-chat",
"object": "model",
"owned_by": "deepseek"
},
{
"id": "deepseek-reasoner",
"object": "model",
"owned_by": "deepseek"
}
]
}from dsbc import DeepSeekClient
# Initialize client
client = DeepSeekClient("your-api-token")
# Get balance
balance = client.get_balance()
for info in balance['balance_infos']:
print(f"Total: {info['total_balance']} {info['currency']}")
# Get models
models = client.get_models()
for model in models['data']:
print(f"{model['id']} (owned by: {model['owned_by']})")# Clone repository
git clone https://github.com/ianmerlos/dsbc.git
cd dsbc/cli
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install with uv (recommended)
uv pip install -e ".[dev]"
# Or install with pip
pip install -e ".[dev]"# Navigate to cli directory
cd cli
# Run all tests
pytest
# Run tests with coverage
pytest --cov=deepseek_balance --cov-report=html
# Run specific test file
pytest tests/test_client.py -v# Navigate to cli directory
cd cli
# Format code with black
black deepseek_balance tests
# Sort imports with isort
isort deepseek_balance tests
# Check code style with flake8
flake8 deepseek_balance tests
# Type checking with mypy
mypy deepseek_balance# Navigate to cli directory
cd cli
# Build package
python -m build
# Check package
twine check dist/*
# Test upload to TestPyPI
twine upload --repository testpypi dist/*
# Upload to PyPI (requires credentials)
twine upload dist/*The repository includes GitHub Actions workflow for:
- Automated testing on multiple Python versions
- Code coverage reporting to Codecov
- Automated releases to PyPI when tags are pushed
- Manual releases via workflow dispatch
# Bump version, commit, and create tag locally
./scripts/set-version.sh 1.2.0
# Push commits and tag to trigger the release workflow
git push && git push --tags
# GitHub Actions will automatically:
# 1. Run tests on all Python versions
# 2. Build the package
# 3. Publish to PyPI
# 4. Create GitHub release- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for your changes
- Ensure code quality checks pass
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see LICENSE file for details.
Important Security Notes:
- Never commit API tokens to version control
- Use environment variables or secure secret management
- Consider using
.envfiles with.gitignore - Rotate tokens regularly
- Monitor usage for suspicious activity
- Issues: GitHub Issues
Note: This tool is not officially affiliated with DeepSeek. Use at your own risk and always review the official DeepSeek API documentation for the most up-to-date information.