Overview
The CLI Proxy API supports multiple authentication methods depending on which endpoints you’re accessing:- API Key Authentication - For main API endpoints (
/v1/*,/v1beta/*) - Management Secret - For management endpoints (
/v0/management/*) - WebSocket Authentication - Optional authentication for WebSocket connections
- Local Password - For localhost-only management access (TUI mode)
API Key Authentication
Configuration
API keys are configured in yourconfig.yaml file:
config.yaml
Using API Keys
Include your API key in theAuthorization header as a Bearer token:
cURL Example
Python Example
JavaScript Example
No Authentication Mode
When no API keys are configured inconfig.yaml, the API allows all requests without authentication:
config.yaml
Management API Authentication
Management endpoints require a secret key for authentication.Configuration
Set the management secret key inconfig.yaml:
config.yaml
If
secret-key is empty, all /v0/management/* endpoints return 404 Not Found.Environment Variable
You can also set the management password via environment variable:Using Management Authentication
Include the secret key in theAuthorization header:
Management API Request
Get Usage Statistics
Update Configuration
Localhost-Only Access
By default, management endpoints are restricted to localhost:config.yaml
config.yaml
WebSocket Authentication
WebSocket connections can optionally require authentication.Configuration
config.yaml
ws-auth: true, WebSocket connections must include the API key in the request.
WebSocket Authentication Example
WebSocket with Auth
cURL WebSocket Upgrade
Provider-Specific API Keys
In addition to client authentication, you can configure upstream provider API keys:Gemini API Keys
config.yaml
Claude API Keys
config.yaml
Codex API Keys
config.yaml
OpenAI-Compatible Providers
config.yaml
OAuth Authentication
The API supports OAuth flows for various providers. OAuth callback endpoints:GET /anthropic/callback- Claude OAuthGET /codex/callback- Codex OAuthGET /google/callback- Google/Gemini OAuthGET /iflow/callback- iFlow OAuthGET /antigravity/callback- Antigravity OAuth
Initiating OAuth
Use management endpoints to start OAuth flows:Get Anthropic Auth URL
Authentication Directory
OAuth tokens and authentication files are stored in the auth directory:config.yaml
List Auth Files
Upload Auth File
Security Best Practices
1
Use Strong Keys
Generate cryptographically secure random keys for both API keys and management secrets:
2
Restrict Management Access
Keep
allow-remote: false unless you specifically need remote management access.3
Enable TLS
Use HTTPS/TLS in production environments:
4
Use Environment Variables
Store sensitive keys in environment variables rather than config files:
5
Rotate Keys Regularly
Implement a key rotation policy for API keys and management secrets.
Error Responses
401 Unauthorized
Returned when authentication fails:404 Not Found (Management API)
Returned when management endpoints are accessed but no secret key is configured:Next Steps
Chat Completions
Start making authenticated API requests
Management API
Manage API configuration and credentials
Model Configuration
Configure provider API keys and models
Security
Learn about security best practices