Skip to content

Switch User Guide In development ​

Getting started

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.

  1. Point the client’s base_url at the local Switch endpoint, set api_key to any value (such as switch), and make requests as usual:

    bash
    curl http://localhost:19090/v1/chat/completions \
      -H "Content-Type: application/json" -H "Authorization: Bearer switch" \
      -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}'
    python
    from 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)
    javascript
    import 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);
  2. With the OpenAI SDK (Python / Node.js), change only base_url/baseURL and api_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

Acting as a local proxy, Switch uses the real provider key stored in its configuration to call downstream services. The api_key on the client side is only a placeholder — just set it to switch.
Integrations

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:

Cursor

Settings (Ctrl+,) → search "AI" → change "OpenAI API Base" to this address → save, and completions and chat automatically go through Switch.

Continue (VS Code)

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.

Cherry Studio

Settings → API configuration → choose "Custom OpenAI-compatible" → enter the address and key → "Test connection".

Lobe Chat

Settings → Language model → OpenAI → enter the API Key and the endpoint address.

Runtime

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.

Advanced

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:

json
{
  "routing": {
    "rules": [
      {
        "pattern": "deepseek-chat",
        "providers": [
          { "name": "Lurus API", "weight": 70 },
          { "name": "DeepSeek Official", "weight": 30 }
        ],
        "strategy": "weighted_random"
      }
    ]
  }
}
Troubleshooting

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·Linux ps 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
  1. Check the logs to confirm routing hit the correct provider.
  2. High latency from overseas providers (OpenAI / Anthropic) is normal (300-1500ms).
  3. 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:

bash
pkill -f LurusSwitch && open -a "Lurus Switch"

Next steps ​

Next steps

Powered by Lurus Technologies