Switch User Guide In development
Connect any OpenAI client to Switch
Once Switch starts, it exposes an OpenAI-compatible API endpoint locally. Change a single line of base_url and all requests are automatically routed by Switch.
Quick integration
Once Switch starts, it exposes an OpenAI-compatible API endpoint locally at http://localhost:19090/v1 (the Switch gateway’s default port is 19090). Change your app’s/SDK’s base_url to this address and all requests are automatically routed by Switch. Set api_key to any value (such as switch); Switch uses the provider key from its configuration.
Point the client’s
base_urlat the local Switch endpoint, setapi_keyto any value (such asswitch), and make requests as usual:bashcurl http://localhost:19090/v1/chat/completions \ -H "Content-Type: application/json" -H "Authorization: Bearer switch" \ -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}'pythonfrom openai import OpenAI client = OpenAI( base_url="http://localhost:19090/v1", api_key="switch", ) resp = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "Hello"}], ) print(resp.choices[0].message.content)javascriptimport OpenAI from "openai"; const client = new OpenAI({ baseURL: "http://localhost:19090/v1", apiKey: "switch", }); const resp = await client.chat.completions.create({ model: "gpt-4o", messages: [{ role: "user", content: "Hello" }], }); console.log(resp.choices[0].message.content);With the OpenAI SDK (Python / Node.js), change only
base_url/baseURLandapi_key; the rest of your calls stay the same — Switch uses the provider key from its configuration to perform the actual routing, and the client never needs to know about the downstream provider.
Why api_key can be any value
api_key on the client side is only a placeholder — just set it to switch.Use it in AI coding tools
For every tool, set the API Base / endpoint address to http://localhost:19090/v1 and the API Key to switch.
Use it in AI coding tools
For every tool, set the API Base / endpoint address to http://localhost:19090/v1 and the API Key to switch:
Settings (Ctrl+,) → search "AI" → change "OpenAI API Base" to this address → save, and completions and chat automatically go through Switch.
Edit ~/.continue/config.json, and for each model entry set "provider": "openai", "apiBase": "http://localhost:19090/v1", "apiKey": "switch", and "model" to deepseek-chat / gpt-4o, etc.
Settings → API configuration → choose "Custom OpenAI-compatible" → enter the address and key → "Test connection".
Settings → Language model → OpenAI → enter the API Key and the endpoint address.
Monitoring, switching, and streaming
Request monitoring
The "Logs" tab shows real-time request logs with the following fields: time (timestamp), model, provider (the actual routing target), latency (ms), tokens (prompt/completion), and status (200 / 4xx-5xx). "Export CSV" lets you export the last 7 days of records for cost analysis.
One-click provider switching
Click the menu bar icon (macOS) / system tray (Windows) to: switch the "current active provider", temporarily disable a provider (for debugging), or view today’s usage overview.
Streaming responses
SSE streaming responses are fully supported and passed through from downstream: after chat.completions.create(..., stream=True), iterate over chunk.choices[0].delta.content.
Load balancing
When a model is configured with multiple providers, you can round-robin or distribute by weight.
Advanced: load balancing
When a model is configured with multiple providers, you can round-robin or distribute by weight:
{
"routing": {
"rules": [
{
"pattern": "deepseek-chat",
"providers": [
{ "name": "Lurus API", "weight": 70 },
{ "name": "DeepSeek Official", "weight": 30 }
],
"strategy": "weighted_random"
}
]
}
}Troubleshooting
Expand the matching symptom to see the steps to resolve it.
Troubleshooting
"connection refused" — the connection was refused
Switch isn’t running or the port is wrong. Check the process and port:
- Process: Windows
tasklist | findstr LurusSwitch/ macOS·Linuxps aux | grep lurus-switch - Port:
curl http://localhost:19090/v1/models
401 / 403 — authentication failed
The provider API Key is misconfigured. Re-enter it in the configuration screen and click "Test" to verify connectivity.
Unusually high latency
- Check the logs to confirm routing hit the correct provider.
- High latency from overseas providers (OpenAI / Anthropic) is normal (300-1500ms).
- Switch to a Lurus API domestic node (typically < 200ms).
The macOS app is unresponsive
Right-click "Quit" in the menu bar and restart, or run in the terminal:
pkill -f LurusSwitch && open -a "Lurus Switch"