route-switch

OpenAI-compatible migration

route-switch is a drop-in OpenAI-compatible endpoint, so applications on the OpenAI SDK migrate by changing one base URL, after which routing, DuckDB analytics, and MIPROv2 optimization become available without a rewrite.

For: Teams already on the OpenAI SDK

If your application already speaks the OpenAI SDK, route-switch is the lowest-friction way to add a gateway: it is an OpenAI-compatible endpoint. Migration is a base-URL change, and everything the gateway offers becomes available afterward without a rewrite.

Step one: the swap

const client = new OpenAI({
  baseURL: "http://localhost:8080/v1", // route-switch
  apiKey: process.env.RS_KEY,
});

That’s the migration. The drop-in OpenAI base_url swap guide covers streaming and edge cases.

Step two: unlock the gateway

Now that traffic flows through route-switch, layer on capability at your own pace:

The trade to weigh

You take on running a self-hosted binary and keeping its SQLite and DuckDB files. In exchange, your prompt, routing, analytics, and optimizer live in one process you control, and your traffic never leaves your infrastructure. If zero-ops access to a wide model catalogue matters more, a hosted aggregator like OpenRouter is the other shape.

Frequently asked questions

How much code changes to migrate?

One field: the client's base URL. Because the endpoint matches OpenAI's /v1/chat/completions contract, the rest of your request code and prompts stay as they are.

What do I get after migrating that I didn't have before?

Config-driven multi-provider routing, per-prompt cost/latency/success analytics in DuckDB, automatic fallback, and closed-loop MIPROv2 prompt optimization.

Related

Run route-switch today

Open source, MIT licensed. One binary, one endpoint, your providers.