Introduction
The CLI Proxy API provides a unified interface for accessing multiple AI model providers through OpenAI-compatible, Claude-compatible, and Gemini-compatible endpoints. The API supports both streaming and non-streaming responses, request authentication, and dynamic model routing.Base URL
The API server runs on a configurable host and port. The default configuration is:config.yaml:
config.yaml
To restrict access to localhost only, set
host: "127.0.0.1" or host: "localhost"HTTPS/TLS Support
The API supports HTTPS with TLS certificates:config.yaml
API Versioning
The CLI Proxy API uses URL path versioning with multiple API versions:OpenAI-Compatible API (v1)
All OpenAI-compatible endpoints are prefixed with/v1:
Gemini-Compatible API (v1beta)
Gemini-compatible endpoints use the/v1beta prefix:
Management API (v0)
Management and administrative endpoints use/v0/management:
Management API endpoints require authentication with a secret key. See the Authentication page for details.
Endpoint Categories
The API is organized into the following functional categories:1. Chat & Completions
OpenAI FormatPOST /v1/chat/completions- OpenAI-compatible chat completionsPOST /v1/completions- OpenAI-compatible text completionsPOST /v1/responses- OpenAI Responses API formatPOST /v1/responses/compact- Compact response formatGET /v1/responses- WebSocket for Responses API
POST /v1/messages- Claude-compatible message APIPOST /v1/messages/count_tokens- Count tokens for Claude requests
POST /v1beta/models/{model}:generateContent- Generate content (non-streaming)POST /v1beta/models/{model}:streamGenerateContent- Generate content (streaming)POST /v1beta/models/{model}:countTokens- Count tokens
2. Model Listing
GET /v1/models- List OpenAI-compatible models (routes based on User-Agent)GET /v1beta/models- List all Gemini-compatible modelsGET /v1beta/models/{model}- Get specific model information
3. OAuth Callbacks
OAuth provider callback endpoints for authentication flows:GET /anthropic/callback- Claude/Anthropic OAuth callbackGET /codex/callback- Codex OAuth callbackGET /google/callback- Google/Gemini OAuth callbackGET /iflow/callback- iFlow OAuth callbackGET /antigravity/callback- Antigravity OAuth callback
4. Management & Configuration
Comprehensive management endpoints at/v0/management/*:
- Usage & Statistics: Get usage data, export/import statistics
- Configuration: View and update server configuration
- API Keys: Manage API keys for various providers
- Logs: Access request logs and error logs
- Authentication: OAuth flows and credential management
5. Control Panel
GET /management.html- Web-based management control panel
Response Formats
The API supports multiple response formats:JSON Responses
All non-streaming endpoints return JSON:Server-Sent Events (SSE)
Streaming endpoints use Server-Sent Events:WebSocket
The Responses API also supports WebSocket connections:Error Responses
All error responses follow this format:400 Bad Request- Invalid request parameters401 Unauthorized- Missing or invalid API key404 Not Found- Endpoint or resource not found429 Too Many Requests- Rate limit exceeded500 Internal Server Error- Server error502 Bad Gateway- Upstream service error503 Service Unavailable- Service temporarily unavailable
CORS Support
The API includes CORS headers on all responses:Rate Limiting & Retries
The API includes built-in retry logic for failed requests:config.yaml
Next Steps
Authentication
Learn how to authenticate API requests
Chat Completions
Make OpenAI-compatible chat requests
Gemini API
Use Gemini-compatible endpoints
Management API
Configure and manage the API server