Environment Configuration
Configuration Features
Loading Method
- • Through environment variables or .env files
- • One-time read at application startup
- • Cannot be modified at runtime
- • Provides basic configuration defaults
Use Cases
- • Server basic parameter configuration
- • Database connection information
- • Security authentication keys
- • Logging and monitoring settings
Server Configuration
Configuration Item | Environment Variable | Default Value | Description |
---|---|---|---|
Service Port | PORT | 3001 | HTTP server listening port |
Service Address | HOST | 0.0.0.0 | HTTP server binding address |
Read Timeout | SERVER_READ_TIMEOUT | 60 | HTTP server read timeout (seconds) |
Write Timeout | SERVER_WRITE_TIMEOUT | 600 | HTTP server write timeout (seconds) |
Idle Timeout | SERVER_IDLE_TIMEOUT | 120 | HTTP connection idle timeout (seconds) |
Graceful Shutdown Timeout | SERVER_GRACEFUL_SHUTDOWN_TIMEOUT | 10 | Service graceful shutdown wait time (seconds) |
Slave Node Mode | IS_SLAVE | false | Slave node identifier for cluster deployment |
Timezone | TZ | Asia/Shanghai | Specify timezone |
Authentication & Database Configuration
Configuration Item | Environment Variable | Default Value | Description |
---|---|---|---|
Admin Key | AUTH_KEY | sk-123456 | Admin access authentication key, please change to a strong password |
Database Connection | DATABASE_DSN | ./data/gpt-load.db | Database connection string (DSN) or file path |
Redis Connection | REDIS_DSN | - | Redis connection string, use memory storage when empty |
Performance & CORS Configuration
Configuration Item | Environment Variable | Default Value | Description |
---|---|---|---|
Max Concurrent Requests | MAX_CONCURRENT_REQUESTS | 100 | Maximum number of concurrent requests allowed by the system |
Enable CORS | ENABLE_CORS | false | Whether to enable Cross-Origin Resource Sharing |
Allowed Origins | ALLOWED_ORIGINS | - | Allowed origins, comma-separated |
Allowed Methods | ALLOWED_METHODS | GET,POST,PUT,DELETE,OPTIONS | Allowed HTTP methods |
Allowed Headers | ALLOWED_HEADERS | * | Allowed request headers, comma-separated |
Allow Credentials | ALLOW_CREDENTIALS | false | Whether to allow sending credentials |
Log Configuration
Configuration Item | Environment Variable | Default Value | Description |
---|---|---|---|
Log Level | LOG_LEVEL | info | Log level: debug, info, warn, error |
Log Format | LOG_FORMAT | text | Log format: text, json |
Enable File Log | LOG_ENABLE_FILE | false | Whether to enable file log output |
Log File Path | LOG_FILE_PATH | ./data/logs/app.log | Log file storage path |
Proxy Configuration
Priority Description
Proxy configuration supports three-tier priority:Group Config > System Config > Environment Config
Environment proxy serves as global fallback configuration, only takes effect when neither system config nor group config has proxy settings.
GPT-Load automatically reads proxy settings from environment variables for upstream AI service provider requests.
Proxy Settings
Configuration Item | Environment Variable | Default Value | Description |
---|---|---|---|
HTTP Proxy | HTTP_PROXY | - | Proxy server address for HTTP requests |
HTTPS Proxy | HTTPS_PROXY | - | Proxy server address for HTTPS requests |
No Proxy | NO_PROXY | - | Hosts or domains that don't need proxy access, comma-separated |
Supported Protocol Formats
HTTP:
http://user:pass@host:port
HTTPS:
https://user:pass@host:port
SOCKS5:
socks5://user:pass@host:port
Environment Configuration Summary
Environment configuration is the foundation of the GPT-Load configuration system, primarily responsible for providing infrastructure parameters required for application operation.
- Basic Service Parameters: Defines core services that application startup and operation depend on, such as server ports, database connections, etc.
- Management Features: Configured through
.env
files or operating system environment variables, loaded at application startup, ensuring configuration stability and consistency. - Usage Advantages: Provides reliable default values for the system while separating sensitive information (such as database passwords, API keys) from the codebase, enhancing security.