A microservice-architected Cloudflare WARP IP rotator and proxy server for OpenCode Zen. Designed to prevent HTTP 429 rate limits, guarantee unique IP rotation per cycle, log usage metrics into SQLite, and display real-time statistics on a clean web dashboard.
- Verified Shared Egress: The proxy and WARP service share one network namespace, so the observed egress path is the path used for upstream requests.
- Microservices Architecture: Decoupled
proxy-server(FastAPI) andwarp-rotator(Cloudflare WARP daemon) services built with Docker Compose. - Clean Management Dashboard: Lightweight Web UI displaying active connections, current location, token statistics, and manual rotation controls.
- SQLite Data Persistence: Stores token consumption, model request counts, and historical IP rotation logs on disk.
- USD Savings Calculator: Estimates cost savings per model based on prompt and completion token rates.
- Table Pagination: Built-in 5-item pagination for model usage and IP rotation log tables.
- Active Flow Locking: Protects active SSE streams from being interrupted during IP rotation —
_active_flows_countis held for the full lifetime of the generator, not just untilreturn. - Rate-limit Preservation: Returns upstream 429 details and
Retry-Afterwithout attempting to bypass model, account, provider, or subscription limits. - Anthropic API Compatibility: Native
/v1/messagesendpoint for Claude clients and the Vercel AI SDK@ai-sdk/anthropicprovider. - Custom Proxy Pool Support: Round-robin outbound proxy pool via
data/proxies.txtorPROXY_LISTenvironment variable.
[OpenCode Client] ──(HTTP/2)──> [Proxy Server (Port 8000)] ──(SQLite)──> [metrics.db]
│
(Inter-Service IPC)
▼
[WARP Rotator (Port 8001)] ──> [Cloudflare WARP Daemon]
│
▼
[OpenCode Zen API Endpoint]
- Proxy Server (
server.py): An OpenAI-compatible API proxy server running onhttp://127.0.0.1:8000/v1. It processes requests, forwards headers dynamically, handles streaming SSE responses, and presents a Web Management Dashboard. - Rotator Module (
rotator.py): Owns the WARP network namespace and exposes a private health/rotation control endpoint. Manual rotation is authenticated; upstream 429 responses are not used as a rotation trigger. - Container Manager (
manager.py): Provides automated ephemeral container lifecycle management. Triggers container self-destruction and re-creation once a defined rotation threshold is reached to ensure fresh hardware identifiers (machine-id).
- OpenAI Standard Compatibility: Fully exposes
/v1/chat/completionsand/v1/modelsendpoints to integrate with standard clients. - Dynamic Header Forwarding: Captures and forwards all incoming client metadata including
x-opencode-*headers and injectsAuthorization: Bearer publiccredentials required by the upstream API. - Verified Public IP Rotation: Validates public IP changes via external IP lookup services to guarantee a distinct IP allocation after every disconnection cycle.
- Active Flow Locking: Prevents IP rotations during active Server-Sent Events (SSE) streaming sessions to prevent connection truncation and stream drops.
- Dynamic Model Auto-Discovery: Periodically queries the upstream API to discover newly available free models without requiring code changes or static lists.
- Web Management Dashboard: Includes a clean, dark-themed web interface accessible at
http://127.0.0.1:8000/dashboardfor monitoring public IP status, active connections, total rotations, and triggering manual rotations.
Run the automated installer script to install Python dependencies, verify system requirements, and automatically configure ~/.config/opencode/opencode.jsonc:
python setup.pyRunning the project in Docker isolates the execution environment, preventing local network configuration changes and ensuring a new environment identity (/etc/machine-id) on every initialization.
- Docker Engine 20.10+
- Docker Compose v2+
docker compose up -d --buildOpen your browser and navigate to:
http://127.0.0.1:8000/dashboard
To manually trigger environment self-destruction and re-create a container with fresh hardware identifiers:
python manager.py- Python 3.8 or higher
- Cloudflare WARP CLI (
warp-cli) installed and added to system PATH - Administrative privileges (required for
warp-clioperations on Windows)
-
Install Python dependencies:
pip install -r requirements.txt
-
Start the rotator background service:
python rotator.py
-
Launch the proxy server:
python server.py
To use the local proxy server within OpenCode, update your configuration file at ~/.config/opencode/opencode.jsonc:
Note: Models are automatically discovered from the proxy server's
/v1/modelsendpoint. You do not need to hardcode model names manually.
The proxy exposes a native Anthropic-compatible /v1/messages endpoint. To use it with OpenCode's Anthropic provider:
{
"provider": {
"my-anthropic-proxy": {
"npm": "@ai-sdk/anthropic",
"options": {
"baseURL": "http://127.0.0.1:8000",
"apiKey": "any"
}
}
}
}Requests sent to
/v1/messagesare translated to OpenAI format internally and routed through the same WARP-protected upstream.
If you want to use your own HTTP/SOCKS5 proxies instead of (or in addition to) Cloudflare WARP:
Option 1 — File: Create data/proxies.txt with one proxy per line:
http://user:pass@proxy1.example.com:8080
socks5://proxy2.example.com:1080
Option 2 — Environment variable:
PROXY_LIST="http://proxy1:8080,socks5://proxy2:1080" docker compose up -dThe proxy pool rotates in round-robin order across all outbound requests.
| Endpoint | Method | Description |
|---|---|---|
/v1/chat/completions |
POST |
OpenAI-compatible chat completion endpoint with automatic retry and IP rotation. |
/v1/messages |
POST |
Anthropic-compatible endpoint (/v1/messages) for Claude clients and @ai-sdk/anthropic. |
/v1/models |
GET |
Returns list of currently discovered active free models. |
/dashboard |
GET |
Renders the HTML Web Management Dashboard. |
/metrics |
GET |
Returns structured JSON metrics including verified IP, uptime, and request counters. |
/api/rotate |
POST |
Triggers an immediate manual IP rotation cycle. |
| Variable | Default Value | Description |
|---|---|---|
OPENCODE_ZEN_PORT |
8000 |
Local port for the proxy server. |
OPENCODE_ZEN_HOST |
127.0.0.1 |
Host address for binding the server (0.0.0.0 in Docker). |
WARP_CHECK_INTERVAL |
15 |
Health check interval in seconds. |
WARP_ROTATION_INTERVAL |
300 |
Periodic IP rotation interval in seconds. |
AUTO_RECYCLE_THRESHOLD |
50 |
Maximum rotations before triggering container environment refresh. |
CORS_ALLOW_ORIGINS |
http://127.0.0.1:8000,http://localhost:8000 |
Comma-separated browser origins allowed to call the proxy. |
WARP_ROTATOR_URL |
http://127.0.0.1:8001 |
Internal rotator endpoint. Do not expose port 8001 publicly. |
The proxy preserves upstream 429 responses, including Retry-After, and does not treat them as a signal to bypass account, model, provider, or subscription limits. The dashboard can trigger manual WARP rotation. In Docker, the proxy shares the rotator's network namespace so the egress path being checked is the path used for upstream requests.
This project is intended for educational, research, and infrastructure resilience testing purposes. Users are responsible for ensuring their usage complies with applicable terms of service and acceptable use policies of third-party service providers. The maintainers assume no liability for account suspensions, service interruptions, or misuse.
This software is released under the MIT License.

{ "provider": { "opencode-zen-local": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://127.0.0.1:8000/v1", "apiKey": "any" }, "name": "OpenCode Zen Local Proxy" } } }