@polyswitch/proxy
v0.1.0
Published
Zero-Code Transparent CLI Proxy Daemon for Polyswitch Enterprise AI Gateway — route Cursor, Claude Code, and any OpenAI-compatible tool through Polyswitch in seconds
Maintainers
Readme
@polyswitch/proxy
Zero-code transparent proxy daemon — route Cursor, Claude Code, VS Code Copilot, or any OpenAI-compatible tool through Polyswitch Enterprise AI Gateway in under 60 seconds. No code changes needed.
How It Works
The proxy starts a local HTTP server that:
- Accepts requests from any tool that talks OpenAI API (Cursor, Claude Code, Python scripts, etc.)
- Forwards them to the Polyswitch Gateway with your API key injected automatically
- Returns the response transparently — the tool doesn't know anything changed
Your API key never needs to be entered into third-party tools.
Installation
# Install globally (recommended for CLI use)
npm install -g @polyswitch/proxy
# Or run directly with npx (no install needed)
npx @polyswitch/proxyQuick Start
Step 1 — Set your environment variables
# Required: Your Polyswitch API key
export POLYSWITCH_API_KEY="pr_your_key_here"
# Optional: The Polyswitch gateway URL (defaults to localhost:3000/api/v1)
export POLYSWITCH_GATEWAY_URL="https://polyswitch.io/api/v1"
# Optional: Proxy port (defaults to 8080)
export POLYSWITCH_PROXY_PORT=8080Step 2 — Start the proxy
polyswitch-proxy
# or
npx @polyswitch/proxyYou'll see:
⚡ Polyswitch Zero-Code Local Proxy listening on http://127.0.0.1:8080
Forwarding traffic to: https://gateway.polyswitch.dev/api/v1
To route Cursor / Claude Code / Python scripts seamlessly, set:
export OPENAI_BASE_URL="http://127.0.0.1:8080"Step 3 — Point your tool at the proxy
export OPENAI_BASE_URL="http://127.0.0.1:8080"That's it. Open Cursor, Claude Code, or run your Python script — all traffic goes through Polyswitch automatically.
Configuration
| Environment Variable | Default | Description |
| ------------------------ | ------------------------------ | -------------------------------------------------------------- |
| POLYSWITCH_API_KEY | — | Your Polyswitch API key (injected into all forwarded requests) |
| POLYSWITCH_GATEWAY_URL | http://localhost:3000/api/v1 | The Polyswitch gateway to forward traffic to |
| POLYSWITCH_PROXY_PORT | 8080 | Local port the proxy listens on |
Use Cases
Cursor IDE
- Start the proxy
- In Cursor settings → Models → set API Base URL to
http://127.0.0.1:8080
Claude Code / Claude CLI
export ANTHROPIC_BASE_URL="http://127.0.0.1:8080"
claudePython scripts
export OPENAI_BASE_URL="http://127.0.0.1:8080"
python your_script.pyAny OpenAI-compatible tool
export OPENAI_BASE_URL="http://127.0.0.1:8080"
export OPENAI_API_KEY="anything" # The proxy injects the real keyProgrammatic Use
You can also use the proxy server in your own Node.js code:
const { createProxyServer } = require('@polyswitch/proxy');
const server = createProxyServer();
server.listen(8080, '127.0.0.1', () => {
console.log('Polyswitch proxy running on port 8080');
});License
MIT © Polyswitch
