Skip to main content

Overview

The CLI Proxy API supports multiple authentication methods depending on which endpoints you’re accessing:
  1. API Key Authentication - For main API endpoints (/v1/*, /v1beta/*)
  2. Management Secret - For management endpoints (/v0/management/*)
  3. WebSocket Authentication - Optional authentication for WebSocket connections
  4. Local Password - For localhost-only management access (TUI mode)

API Key Authentication

Configuration

API keys are configured in your config.yaml file:
config.yaml

Using API Keys

Include your API key in the Authorization header as a Bearer token:
cURL Example
Python Example
JavaScript Example

No Authentication Mode

When no API keys are configured in config.yaml, the API allows all requests without authentication:
config.yaml
This mode should only be used in development or when the API is behind a secure gateway.

Management API Authentication

Management endpoints require a secret key for authentication.

Configuration

Set the management secret key in config.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:
The environment variable takes precedence over the config file.

Using Management Authentication

Include the secret key in the Authorization header:
Management API Request
Get Usage Statistics
Update Configuration

Localhost-Only Access

By default, management endpoints are restricted to localhost:
config.yaml
To allow remote access:
config.yaml
Enabling remote management access exposes sensitive configuration endpoints to the network. Ensure you use a strong secret key and proper network security.

WebSocket Authentication

WebSocket connections can optionally require authentication.

Configuration

config.yaml
When ws-auth: true, WebSocket connections must include the API key in the request.

WebSocket Authentication Example

WebSocket with Auth
For the OpenAI Responses WebSocket endpoint:
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 OAuth
  • GET /codex/callback - Codex OAuth
  • GET /google/callback - Google/Gemini OAuth
  • GET /iflow/callback - iFlow OAuth
  • GET /antigravity/callback - Antigravity OAuth

Initiating OAuth

Use management endpoints to start OAuth flows:
Get Anthropic Auth URL
The response contains an authorization URL to visit in your browser. After authorization, the callback endpoint receives the OAuth tokens.

Authentication Directory

OAuth tokens and authentication files are stored in the auth directory:
config.yaml
Authentication files can be managed via the Management API:
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