Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

merlos/dsbc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dsbc - DeepSeek Tools Collection

PyPI version Python versions License: MIT GitHub Actions

A collection of tools for interacting with DeepSeek API, starting with a Python CLI tool to check account balances and view available models.

Features

  • 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 pip and uv
  • Type hints - Full type annotations for better IDE support
  • Comprehensive tests - Well-tested with pytest
  • GitHub Actions - Automated releases to PyPI

Installation

Install with pip

# Install from PyPI
pip install dsbc

# Install with development dependencies
pip install dsbc[dev]

# Install with uv support
pip install dsbc[uv]

Install with uv

# Install from PyPI
uv pip install dsbc

# Install with development dependencies
uv pip install "dsbc[dev]"

Install from source

# 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 .

Quick Start

# 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

Usage

Basic Commands

# 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 --health

Environment Variables

The tool checks for API tokens in this order of priority:

  1. --token command-line argument
  2. DEEPSEEK_API_TOKEN environment variable (default)
  3. DEEPSEEK_TOKEN environment variable
  4. DEEPSEEK_API_KEY environment variable
  5. OPENAI_API_KEY environment variable (for compatibility)
# Set default environment variable
export DEEPSEEK_API_TOKEN="sk-abc123def456"

# Or use a different variable
export DEEPSEEK_TOKEN="sk-xyz789uvw012"

Examples

Example 1: Basic Balance Check

$ dsbc
==================================================
DEEPSEEK ACCOUNT BALANCE
==================================================
Status:            ✅ Available
Currency:          USD
Total Balance:     18.87 USD
Topped-up Balance: 18.87 USD
Granted Balance:   0.00 USD
==================================================

Example 2: Check Models

$ dsbc --models
==================================================
DEEPSEEK AVAILABLE MODELS
==================================================
  - deepseek-chat  (owned by: deepseek)
  - deepseek-reasoner  (owned by: deepseek)
==================================================

Example 3: JSON Output

$ 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"
    }
  ]
}

Example 4: Python Module Usage

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']})")

Development

Setting Up Development Environment

# 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]"

Running Tests

# 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

Code Quality

# 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

Building and Publishing

# 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/*

GitHub Actions

The repository includes GitHub Actions workflow for:

  1. Automated testing on multiple Python versions
  2. Code coverage reporting to Codecov
  3. Automated releases to PyPI when tags are pushed
  4. Manual releases via workflow dispatch

Release Process

# 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

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests for your changes
  5. Ensure code quality checks pass
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

License

MIT License - see LICENSE file for details.

Security

Important Security Notes:

  • Never commit API tokens to version control
  • Use environment variables or secure secret management
  • Consider using .env files with .gitignore
  • Rotate tokens regularly
  • Monitor usage for suspicious activity

Support


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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •