Route AI provider traffic through your own reverse proxy, load balancer, or custom API gateway. Per-provider base URL overrides, built-in proxy mode for Claude, and centralized token distribution.
scorpiox code supports routing all AI provider API traffic through custom endpoints. Every provider — Claude, OpenAI, Gemini — can have its base URL overridden to point at your own infrastructure. The Claude Code provider additionally has a dedicated proxy mode with strict-fail semantics.
Override OPENAI_BASE_URL, GEMINI_BASE_URL, or CLAUDE_CODE_PROXY_URL to route each provider through different endpoints.
When CLAUDE_CODE_PROXY_STRICT=1, requests fail immediately if the proxy is unreachable — no silent fallback to direct API.
scorpiox-server-fetchtoken distributes API keys to agents via TCP, with IP whitelist and multi-key rotation support.
scorpiox-traffic captures HTTP/HTTPS conversations in HAR, JSONL, or raw format for debugging and auditing.
The Claude Code provider in scorpiox code has a built-in proxy subsystem implemented in sx_provider_claude_code.c. When enabled, all API requests to Anthropic are routed through the configured proxy hostname instead of the default API endpoint.
When CLAUDE_CODE_PROXY_ENABLED=1, the C HTTP client replaces the default Anthropic API hostname with the value of CLAUDE_CODE_PROXY_URL. The request path, headers, and body remain identical — your proxy only needs to forward traffic to api.anthropic.com.
anthropic.scorpiox.net. Set CLAUDE_CODE_PROXY_URL to your own domain to use a self-hosted reverse proxy.
| Setting | Behavior |
|---|---|
| PROXY_STRICT=0 | If proxy is unreachable, fall back to direct API call (default) |
| PROXY_STRICT=1 | If proxy is unreachable, the request fails with an error — no fallback |
Every AI provider in scorpiox code supports a base URL override. This lets you point API requests at any compatible endpoint: a corporate proxy, a local cache, a regional mirror, or a custom gateway.
| Key | Provider | Default |
|---|---|---|
| OPENAI_BASE_URL | OpenAI / GPT | api.openai.com |
| GEMINI_BASE_URL | Google Gemini | generativelanguage.googleapis.com |
| CLAUDE_CODE_PROXY_URL | Claude Code | anthropic.scorpiox.net |
| ROUTER_URL | Claude (generic router) | empty — direct |
| WASM_API_PROXY | WASM builds | empty — direct |
The ROUTER_URL config key points scorpiox code at a centralized router or load balancer. This is used by the Claude provider (sx_claude.c) to distribute requests across multiple API keys or backends.
The router sits between scorpiox code and the upstream provider APIs. It can:
Distribute requests across multiple API keys to spread rate limits and billing.
Log every prompt and completion for compliance, cost tracking, or debugging.
Enforce per-user or per-team token budgets before requests reach the provider.
scorpiox-server-fetchtoken is a TCP server that bridges local agents to upstream HTTP token endpoints. It distributes API keys to scorpiox code instances without embedding secrets in config files or environment variables.
| Key | Type | Default | Description |
|---|---|---|---|
| FETCHTOKEN_LISTEN_PORT | string | 9800 | TCP port for the local listener |
| FETCHTOKEN_UPSTREAM_BASE | string | empty | Upstream base URL for token proxy |
| FETCHTOKEN_API_KEY | string | empty | Single API key |
| FETCHTOKEN_API_KEYS | string | empty | Multiple keys (comma-separated, with labels) |
| FETCHTOKEN_API_KEY_REQUIRED | boolean | false | Require API key for access |
| FETCHTOKEN_IP_WHITELIST | string | empty | CIDR-based IP whitelist |
| FETCHTOKEN_ACCESS_LOG | boolean | false | Enable access logging |
The fetchtoken server supports two wire protocols:
Simple type-based request. Client sends a provider type (claude, codex, gemini) and receives a token back.
Authenticated requests with API key and structured payloads. Supports multi-type dispatch and key labels.
scorpiox-traffic is an HTTP/HTTPS traffic capture CLI built in C. It launches an embedded MITM proxy, sets HTTP_PROXY/HTTPS_PROXY for a child process, and records all conversations.
| Format | Description |
|---|---|
| raw | Full request/response bodies as files |
| summary.json | Metadata only — URLs, status codes, timing |
| conversation.jsonl | Structured prompt/completion pairs |
| har | HTTP Archive format (Chrome DevTools compatible) |
8899. Override with TRAFFIC_PORT in scorpiox-env.txt. Sessions are stored in ~/.scorpiox/traffic/.
Complete list of proxy-related configuration keys in scorpiox-env.txt:
| Key | Type | Default | Description |
|---|---|---|---|
| CLAUDE_CODE_PROXY_ENABLED | boolean | 0 | Enable proxy routing for Claude Code requests |
| CLAUDE_CODE_PROXY_STRICT | boolean | 0 | Strict proxy mode — fail if proxy unreachable |
| CLAUDE_CODE_PROXY_URL | string | anthropic.scorpiox.net | Proxy hostname for Claude Code requests |
| OPENAI_BASE_URL | string | empty | Custom base URL for OpenAI API |
| GEMINI_BASE_URL | string | empty | Custom base URL for Gemini API |
| ROUTER_URL | string | empty | URL for the scorpiox router/load-balancer |
| WASM_API_PROXY | string | empty | API proxy URL for WASM builds |
| CURL_CA_BUNDLE | string | empty | Path to CA certificate bundle for TLS |
| TRAFFIC_PORT | string | 8899 | Port for scorpiox-traffic MITM proxy |
| FETCHTOKEN_LISTEN_PORT | string | 9800 | Port for the local fetchtoken server |