ccproxy.config¶
ccproxy.config
¶
Configuration module for Claude Proxy API Server.
AuthSettings
¶
Bases: BaseModel
Combined authentication and credentials configuration.
validate_oauth
classmethod
¶
Validate and convert OAuth configuration.
Source code in ccproxy/config/auth.py
validate_storage
classmethod
¶
Validate and convert storage configuration.
Source code in ccproxy/config/auth.py
DockerSettings
¶
Bases: BaseModel
Docker configuration settings for running Claude commands in containers.
validate_docker_volumes
classmethod
¶
validate_docker_home_directory
classmethod
¶
Validate and normalize Docker home directory (host path).
Source code in ccproxy/config/docker_settings.py
validate_docker_workspace_directory
classmethod
¶
Validate and normalize Docker workspace directory (host path).
Source code in ccproxy/config/docker_settings.py
setup_docker_configuration
¶
Set up Docker volumes and user mapping configuration.
Source code in ccproxy/config/docker_settings.py
ConfigLoader
¶
Load configuration from multiple sources.
Source code in ccproxy/config/loader.py
load
¶
Load configuration from multiple sources.
Priority: ENV > config file > defaults
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_file
|
Path | None
|
Optional path to config file |
None
|
Returns:
Type | Description |
---|---|
Settings
|
Settings instance with loaded configuration |
Raises:
Type | Description |
---|---|
ConfigurationError
|
If config file is invalid or cannot be loaded |
Source code in ccproxy/config/loader.py
Settings
¶
Bases: BaseSettings
Configuration settings for the Claude Proxy API Server.
Settings are loaded from environment variables, .env files, and TOML configuration files. Environment variables take precedence over .env file values. TOML configuration files are loaded in the following order: 1. .ccproxy.toml in current directory 2. ccproxy.toml in git repository root 3. config.toml in XDG_CONFIG_HOME/ccproxy/
validate_server
classmethod
¶
Validate and convert server settings.
Source code in ccproxy/config/settings.py
validate_security
classmethod
¶
Validate and convert security settings.
Source code in ccproxy/config/settings.py
validate_cors
classmethod
¶
Validate and convert CORS settings.
Source code in ccproxy/config/settings.py
validate_claude
classmethod
¶
Validate and convert Claude settings.
Source code in ccproxy/config/settings.py
validate_reverse_proxy
classmethod
¶
Validate and convert reverse proxy settings.
Source code in ccproxy/config/settings.py
validate_auth
classmethod
¶
Validate and convert auth settings.
Source code in ccproxy/config/settings.py
validate_docker_settings
classmethod
¶
Validate and convert Docker settings.
Source code in ccproxy/config/settings.py
validate_observability
classmethod
¶
Validate and convert observability settings.
Source code in ccproxy/config/settings.py
validate_scheduler
classmethod
¶
Validate and convert scheduler settings.
Source code in ccproxy/config/settings.py
validate_pricing
classmethod
¶
Validate and convert pricing settings.
Source code in ccproxy/config/settings.py
setup_claude_cli_path
¶
Set up Claude CLI path in environment if provided or found.
Source code in ccproxy/config/settings.py
model_dump_safe
¶
load_toml_config
classmethod
¶
Load configuration from a TOML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
toml_path
|
Path
|
Path to the TOML configuration file |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict[str, Any]
|
Configuration data from the TOML file |
Raises:
Type | Description |
---|---|
ValueError
|
If the TOML file is invalid or cannot be read |
Source code in ccproxy/config/settings.py
load_config_file
classmethod
¶
Load configuration from a file based on its extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_path
|
Path
|
Path to the configuration file |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict[str, Any]
|
Configuration data from the file |
Raises:
Type | Description |
---|---|
ValueError
|
If the file format is unsupported or invalid |
Source code in ccproxy/config/settings.py
from_toml
classmethod
¶
Create Settings instance from TOML configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
toml_path
|
Path | None
|
Path to TOML configuration file. If None, auto-discovers file. |
None
|
**kwargs
|
Any
|
Additional keyword arguments to override config values |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Settings |
Settings
|
Configured Settings instance |
Source code in ccproxy/config/settings.py
from_config
classmethod
¶
Create Settings instance from configuration file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_path
|
Path | str | None
|
Path to configuration file. Can be: - None: Auto-discover config file or use CONFIG_FILE env var - Path or str: Use this specific config file |
None
|
**kwargs
|
Any
|
Additional keyword arguments to override config values |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Settings |
Settings
|
Configured Settings instance |
Source code in ccproxy/config/settings.py
load_config
¶
get_settings
¶
Get the global settings instance with configuration file support.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_path
|
Path | str | None
|
Optional path to configuration file. If None, uses CONFIG_FILE env var or auto-discovers config file. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Settings |
Settings
|
Configured Settings instance |
Source code in ccproxy/config/settings.py
validate_config_dict
¶
Validate configuration dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
dict[str, Any]
|
Configuration dictionary to validate |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
The validated configuration dictionary |
Raises:
Type | Description |
---|---|
ConfigValidationError
|
If configuration is invalid |
Source code in ccproxy/config/validators.py
validate_cors_origins
¶
Validate CORS origins.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
origins
|
list[str]
|
List of origin URLs to validate |
required |
Returns:
Type | Description |
---|---|
list[str]
|
The validated list of origins |
Raises:
Type | Description |
---|---|
ConfigValidationError
|
If any origin is invalid |
Source code in ccproxy/config/validators.py
validate_host
¶
Validate host address.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
host
|
str
|
Host address to validate |
required |
Returns:
Type | Description |
---|---|
str
|
The validated host address |
Raises:
Type | Description |
---|---|
ConfigValidationError
|
If host is invalid |
Source code in ccproxy/config/validators.py
validate_log_level
¶
Validate log level.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level
|
str
|
Log level to validate |
required |
Returns:
Type | Description |
---|---|
str
|
The validated log level |
Raises:
Type | Description |
---|---|
ConfigValidationError
|
If log level is invalid |
Source code in ccproxy/config/validators.py
validate_path
¶
Validate file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str | Path
|
Path to validate |
required |
Returns:
Type | Description |
---|---|
Path
|
The validated Path object |
Raises:
Type | Description |
---|---|
ConfigValidationError
|
If path is invalid |
Source code in ccproxy/config/validators.py
validate_port
¶
Validate port number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
port
|
int | str
|
Port number to validate |
required |
Returns:
Type | Description |
---|---|
int
|
The validated port number |
Raises:
Type | Description |
---|---|
ConfigValidationError
|
If port is invalid |
Source code in ccproxy/config/validators.py
validate_timeout
¶
Validate timeout value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout
|
int | float
|
Timeout value to validate |
required |
Returns:
Type | Description |
---|---|
int | float
|
The validated timeout value |
Raises:
Type | Description |
---|---|
ConfigValidationError
|
If timeout is invalid |
Source code in ccproxy/config/validators.py
validate_url
¶
Validate URL format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
URL to validate |
required |
Returns:
Type | Description |
---|---|
str
|
The validated URL |
Raises:
Type | Description |
---|---|
ConfigValidationError
|
If URL is invalid |