-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.env.example
More file actions
114 lines (98 loc) · 4.68 KB
/
Copy path.env.example
File metadata and controls
114 lines (98 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Claude Code Proxy Environment Variables
# Copy this file to .env and update with your actual values
# For Docker deployment, use .env.docker.example instead
# =============================================================================
# PROXY CONFIGURATION
# =============================================================================
# Port for the proxy server (default: 4181)
PROXY_PORT=4181
# =============================================================================
# API KEYS (REQUIRED)
# =============================================================================
# Z.AI API configuration - Get your API key from https://z.ai
ZAI_API_KEY=your_zai_api_key_here
# Optional: override provider base URL
# ZAI_BASE_URL=https://api.z.ai/api/anthropic
# Anthropic API configuration - Get your API key from https://console.anthropic.com
# Optional: only used as last-resort fallback after Z.AI and Claude subscription
ANTHROPIC_API_KEY=your_anthropic_api_key_here
# Optional: override provider base URL
# ANTHROPIC_BASE_URL=https://api.anthropic.com
# OpenRouter fallback
OPENROUTER_API_KEY=your_openrouter_api_key_here
# Optional: override provider base URL
# OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
# Optional: keep OpenRouter fallback from hanging behind slow upstreams
# OPENROUTER_TIMEOUT_MS=60000
# OPENROUTER_MAX_RETRIES=0
# Claude subscription fallback (uses OAuth from ~/.claude/.credentials.json)
# Set to "false" to disable this fallback tier
# CLAUDE_SUBSCRIPTION_ENABLED=true
# Optional: override subscription base URL
# CLAUDE_SUBSCRIPTION_BASE_URL=https://api.anthropic.com
# Optional: override credentials file path (default: ~/.claude/.credentials.json)
# CLAUDE_CREDENTIALS_PATH=~/.claude/.credentials.json
# =============================================================================
# DATABASE CONFIGURATION (Optional - for usage tracking)
# =============================================================================
# PostgreSQL Database Configuration
# Uncomment to enable PostgreSQL usage tracking
# DATABASE_URL=postgresql://postgres:postgres@localhost:5432/claude_proxy
# DB_HOST=localhost
# DB_PORT=5432
# DB_NAME=claude_proxy
# DB_USER=postgres
# DB_PASSWORD=postgres
# DB_SSL=false
# DB_MAX_CONNECTIONS=10
# DB_IDLE_TIMEOUT_MS=30000
# DB_CONNECTION_TIMEOUT_MS=2000
# =============================================================================
# LOGGING CONFIGURATION
# =============================================================================
# Log level: debug, info, warn, error, silent (default: info)
LOG_LEVEL=info
# =============================================================================
# CIRCUIT BREAKER CONFIGURATION
# =============================================================================
# Automatic provider switching based on health and rate limits
# Enabled by default - set to "false" to disable
CIRCUIT_BREAKER_ENABLED=true
# Time in milliseconds to wait before retrying a failed provider (default: 60000 = 1 minute)
CIRCUIT_BREAKER_COOLDOWN_MS=60000
# Number of consecutive errors before marking provider as degraded (default: 3)
CIRCUIT_BREAKER_DEGRADED_THRESHOLD=3
# Number of consecutive errors before marking provider as unavailable (default: 5)
CIRCUIT_BREAKER_UNAVAILABLE_THRESHOLD=5
# Time in milliseconds between health checks for unhealthy providers (default: 30000 = 30 seconds)
CIRCUIT_BREAKER_HEALTH_CHECK_INTERVAL=30000
# =============================================================================
# QUOTA CONFIGURATION
# =============================================================================
# Weekly token limit for Anthropic before switching to Z.AI (0 = no limit)
# Example: 1,000,000 tokens per week
ANTHROPIC_WEEKLY_LIMIT=0
# Percentage of weekly limit to trigger fallback to Z.AI (default: 80)
# When Anthropic usage reaches this percentage, requests go to Z.AI
QUOTA_WARNING_THRESHOLD=80
# =============================================================================
# DOCKER DEPLOYMENT
# =============================================================================
# For Docker deployment, copy .env.docker.example to .env.docker
# This will provide Docker-specific configuration with all necessary variables
# Command: cp .env.docker.example .env.docker
# Then update with your actual API keys
# =============================================================================
# USAGE EXAMPLES
# =============================================================================
# Local development:
# npm run build
# npm start
#
# Docker deployment:
# cp .env.docker.example .env.docker
# # Edit .env.docker with your API keys
# docker-compose --env-file .env.docker up -d
#
# View logs:
# docker-compose --env-file .env.docker logs -f cc-proxy