A configurable proxy application designed to route and manage requests across multiple LLM (Large Language Model) vendors.
For detailed server installation instructions, see INSTALL.md.
- Docker and Docker Compose
- Python 3.13 (for local development)
- uv package manager
- Install venv
make install
- Generate secrets for environment setup
make secrets
- Format changes
make format
- Lint changes
make lint
- Run tests
make test
-
Generate Secrets
# Generate secure secrets and write them to .env file uv run python -m src.cli.generate_secrets # This will automatically: # - Generate random secrets for APP_SECRET_KEY, VENDOR_ENCRYPTION_KEY, DB_PASSWORD, ADMIN_PASSWORD # - Append them to .env file with "# Generated secrets" comment # - Set file permissions to 600 for security
-
Simple AI Client
# usage: simple_ai_client.py [-h] [--vendor VENDOR] [--vendor-url VENDOR_URL] [--model MODEL] [--token TOKEN] [--stream] [--prompt PROMPT] # # CLI for interacting with AI models (DeepSeek/OpenAI compatible API) # # options: # -h, --help show this help message and exit # --vendor VENDOR AI vendor (deepseek, ...) # --vendor-url VENDOR_URL # AI vendor URL (https://api.deepseek.com/v1, ...) # --model MODEL Model name (e.g. deepseek-chat) # --token TOKEN Authorization token (or environment variable) # --stream Stream mode # --prompt PROMPT Prompt text # Example of running simple_ai_client via CLI uv run python -m src.cli.simple_ai_client --vendor openai --prompt "Hi, how are you?" --user-id 1 # Example with additional parameters uv run python -m src.cli.simple_ai_client --vendor openai --prompt "Tell me a joke" \ --user-id 1 --model gpt-3.5-turbo --temperature 0.7 # To get help on all available options uv run python -m src.cli.simple_ai_client --help
-
User management (change password)
# Usage: python -m src.modules.cli.management [OPTIONS] # Change the admin password. # Options: # --help Show this help message # --username TEXT Admin username # --random-password Generate a random password. # --random-password-length INTEGER Set length of generated random password. # Example: change password for admin to auto-generated password with length 32 symbols uv run python -m src.modules.cli.management --username admin --random-password --random-password-length 32 # Example: change password for my-user to password from stdin uv run python -m src.modules.cli.management --username my-user # === # Changing admin password... # Set a new password for my-user # New Password: <INPUT> # Repeat for confirmation: <INPUT>
When enabled, the Swagger documentation is available at /docs and ReDoc at /redoc.
The application now supports encrypted storage of vendor API keys using AES-256-GCM encryption. This ensures that sensitive API credentials are not stored in plaintext in the database.
The encryption key is now automatically generated along with other secrets using the make secrets command. See the Environment Setup section above for detailed instructions.
The encryption key (VENDOR_ENCRYPTION_KEY) is automatically:
- Generated with 32 characters of secure random data
- Written to your
.envfile - Protected with proper file permissions (600)
API keys will be automatically encrypted when:
- Creating new vendors through the admin interface
- Updating existing vendor API keys
-
Copy the environment template:
cp .env.template .env
-
Generate secure secrets for your environment:
make secrets
This command will automatically:
- Generate secure random secrets for your application
- Write them directly to your
.envfile with a "# Generated secrets" comment - Set proper file permissions (600) for security
- Display success messages in the console
The generated secrets include:
APP_SECRET_KEY- Secret key for the applicationVENDOR_ENCRYPTION_KEY- Key for encrypting vendor API keysDB_PASSWORD- Database passwordADMIN_PASSWORD- Default admin password
-
Review and update your
.envfile with any additional required settings.
| Variable | Type | Default | Required | Description |
|---|---|---|---|---|
| API_DOCS_ENABLED | bool | false | Enable FastAPI docs (Swagger/ReDoc) | |
| APP_SECRET_KEY | string | - | yes | Secret key |
| APP_HOST | string | localhost | Host address for the application | |
| APP_PORT | int | 8003 | Port for the application | |
| JWT_ALGORITHM | string | HS256 | JWT algorithm | |
| HTTP_PROXY_URL | string | - | Socks5 Proxy URL | |
| VENDOR_DEFAULT_TIMEOUT | int | 30 | Default HTTP timeout for vendor requests (seconds) | |
| VENDOR_DEFAULT_RETRIES | int | 3 | Default HTTP retry attempts for vendor requests | |
| VENDOR_ENCRYPTION_KEY | string | - | yes | Secret key for vendor API key encryption |
| Variable | Type | Default | Required | Description |
|---|---|---|---|---|
| ADMIN_USERNAME | string | admin | Default admin username | |
| ADMIN_PASSWORD | string | code-admin! | Default (initial) admin password | |
| ADMIN_SESSION_EXPIRATION_TIME | int | 172800 | Admin session expiration time (seconds) | |
| ADMIN_BASE_URL | string | /cadm | Admin panel base URL | |
| ADMIN_TITLE | string | CodeAgent Admin | Admin panel title |
| Variable | Type | Default | Required | Description |
|---|---|---|---|---|
| LOG_LEVEL | string | INFO | One of DEBUG / INFO / WARNING / ERROR / CRITICAL | |
| LOG_SKIP_STATIC_ACCESS | bool | false | Skip logging access to static files | |
| LOG_FORMAT | string | [%(asctime)s] %(levelname)s [%(filename)s:%(lineno)s] %(message)s | Log message format | |
| LOG_DATEFMT | string | %d.%m.%Y %H:%M:%S | Date format for log timestamps |
| Variable | Type | Default | Required | Description |
|---|---|---|---|---|
| FLAG_OFFLINE_MODE | bool | false | Enable offline mode |
| Variable | Type | Default | Required | Description |
|---|---|---|---|---|
| DB_DRIVER | string | postgresql+asyncpg | SQLAlchemy driver | |
| DB_HOST | string | localhost | Database host | |
| DB_PORT | int | 5432 | Database port | |
| DB_USERNAME | string | postgres | Database username | |
| DB_PASSWORD | string | postgres | Database password | |
| DB_DATABASE | string | code_agent | Database name | |
| DB_POOL_MIN_SIZE | int | - | Pool min size | |
| DB_POOL_MAX_SIZE | int | - | Pool max size | |
| DB_ECHO | bool | false | SQLAlchemy echo |
These are used by src/cli/simple_ai_client.py.
| Variable | Type | Default | Required | Description |
|---|---|---|---|---|
| CLI_AI_API_TOKEN | string | - | yes* | Authorization token for the CLI (required unless --token is provided) |
| CLI_AI_TEMPERATURE | float | 0.7 | Sampling temperature | |
| CLI_AI_MAX_TOKENS | int | 1000 | Max tokens in completion | |
| CLI_AI_TIMEOUT | int | 3600 | HTTP timeout (seconds) |
| Variable | Type | Default | Required | Description |
|---|---|---|---|---|
| APP_SERVICE | string | - | yes (container) | Selects entrypoint behavior: web / test / lint |
| DOCKER_IMAGE | string | - | yes (docker-compose) | Image tag used by docker-compose.yml |
| APP_PORT | int | - | yes (docker-compose) | Port mapping for docker-compose.yml (should match application APP_PORT) |