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 ItemEnvironment VariableDefault ValueDescription
Service PortPORT3001HTTP server listening port
Service AddressHOST0.0.0.0HTTP server binding address
Read TimeoutSERVER_READ_TIMEOUT60HTTP server read timeout (seconds)
Write TimeoutSERVER_WRITE_TIMEOUT600HTTP server write timeout (seconds)
Idle TimeoutSERVER_IDLE_TIMEOUT120HTTP connection idle timeout (seconds)
Graceful Shutdown TimeoutSERVER_GRACEFUL_SHUTDOWN_TIMEOUT10Service graceful shutdown wait time (seconds)
Slave Node ModeIS_SLAVEfalseSlave node identifier for cluster deployment
TimezoneTZAsia/ShanghaiSpecify timezone

Authentication & Database Configuration

Configuration ItemEnvironment VariableDefault ValueDescription
Admin KeyAUTH_KEYsk-123456Admin access authentication key, please change to a strong password
Database ConnectionDATABASE_DSN./data/gpt-load.dbDatabase connection string (DSN) or file path
Redis ConnectionREDIS_DSN-Redis connection string, use memory storage when empty

Performance & CORS Configuration

Configuration ItemEnvironment VariableDefault ValueDescription
Max Concurrent RequestsMAX_CONCURRENT_REQUESTS100Maximum number of concurrent requests allowed by the system
Enable CORSENABLE_CORSfalseWhether to enable Cross-Origin Resource Sharing
Allowed OriginsALLOWED_ORIGINS-Allowed origins, comma-separated
Allowed MethodsALLOWED_METHODSGET,POST,PUT,DELETE,OPTIONSAllowed HTTP methods
Allowed HeadersALLOWED_HEADERS*Allowed request headers, comma-separated
Allow CredentialsALLOW_CREDENTIALSfalseWhether to allow sending credentials

Log Configuration

Configuration ItemEnvironment VariableDefault ValueDescription
Log LevelLOG_LEVELinfoLog level: debug, info, warn, error
Log FormatLOG_FORMATtextLog format: text, json
Enable File LogLOG_ENABLE_FILEfalseWhether to enable file log output
Log File PathLOG_FILE_PATH./data/logs/app.logLog 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 ItemEnvironment VariableDefault ValueDescription
HTTP ProxyHTTP_PROXY-Proxy server address for HTTP requests
HTTPS ProxyHTTPS_PROXY-Proxy server address for HTTPS requests
No ProxyNO_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.