tourze/deep-seek-api-bundle

DeepSeek API integration bundle for Symfony

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:symfony-bundle

pkg:composer/tourze/deep-seek-api-bundle

This package is auto-updated.

Last update: 2025-11-16 09:25:26 UTC


README

English | 中文

A Symfony bundle for integrating with DeepSeek API, providing API key management, model listing, and balance checking capabilities.

Features

  • Multiple API key management with automatic rotation
  • List available models for each API key
  • Check account balance in multiple currencies
  • Validate API keys
  • Command-line tools for API interaction

Installation

composer require tourze/deep-seek-api-bundle

Configuration

Configure your API keys in your Symfony configuration:

# config/packages/deep_seek_api.yaml
deep_seek_api:
    api_keys:
        - 'your-api-key-1'
        - 'your-api-key-2'

Commands

Analyze Balance Trends

Analyze balance changes and usage patterns over time.

# Analyze balance for the last 7 days
bin/console deep-seek:analyze-balance

# Analyze balance for specific number of days
bin/console deep-seek:analyze-balance --days=30

# Analyze with specific time interval (hourly, daily, weekly)
bin/console deep-seek:analyze-balance --interval=daily

# Display in specific currency
bin/console deep-seek:analyze-balance --currency=CNY

# Show alerts for significant changes
bin/console deep-seek:analyze-balance --show-alerts

Manage API Keys

Manage DeepSeek API keys including listing, adding, and deactivating.

# List all API keys
bin/console deep-seek:api-key list

# Add a new API key
bin/console deep-seek:api-key add sk-your-api-key --name="Production Key"

# Deactivate an API key
bin/console deep-seek:api-key deactivate sk-your-api-key

# Activate an API key
bin/console deep-seek:api-key activate sk-your-api-key

# Show API key details
bin/console deep-seek:api-key show sk-your-api-key

Check Balance

Check the current balance for all API keys or a specific key.

# Check balance for all keys
bin/console deepseek:balance:check

# Check balance with detailed output
bin/console deepseek:balance:check --verbose

List Models

List all available models from DeepSeek API.

# List models for all keys
bin/console deepseek:models:list

# List models in JSON format
bin/console deepseek:models:list --json

Validate API Key

Validate whether API keys are working correctly.

# Validate all API keys
bin/console deepseek:api-key:validate --all-keys

# Validate specific API key
bin/console deepseek:api-key:validate --key=sk-your-api-key

Sync Data

Synchronize models and balance data from DeepSeek API.

# Sync all data (models and balances)
bin/console deep-seek:sync-data

# Sync only models
bin/console deep-seek:sync-data --models-only

# Sync only balances
bin/console deep-seek:sync-data --balances-only

# Force sync even if recently synced
bin/console deep-seek:sync-data --force

Usage in Code

Using DeepSeekService

use Tourze\DeepSeekApiBundle\Service\DeepSeekService;

class MyService
{
    public function __construct(
        private DeepSeekService $deepSeekService
    ) {}

    public function example(): void
    {
        // List models
        $models = $this->deepSeekService->listModels();
        
        // Check balance
        $balance = $this->deepSeekService->getBalance();
        
        // Validate API key
        $isValid = $this->deepSeekService->validateApiKey('your-api-key');
    }
}

Managing API Keys

use Tourze\DeepSeekApiBundle\Service\ApiKeyManager;

class MyKeyManager
{
    public function __construct(
        private ApiKeyManager $apiKeyManager
    ) {}

    public function example(): void
    {
        // Add a new API key
        $this->apiKeyManager->addApiKey('new-api-key');
        
        // Rotate to next key
        $this->apiKeyManager->rotateToNextKey();
        
        // Get current key
        $currentKey = $this->apiKeyManager->getCurrentKey();
        
        // Mark key as invalid
        $this->apiKeyManager->markKeyAsInvalid('bad-key');
    }
}