Switching LLM providers without rewriting code

Short answerPick a provider whose API your code already speaks. Lyceum's serverless inference serves open models through an OpenAI-compatible API, so you change the base URL, key and model ID, billed per token. An open-source gateway such as LiteLLM keeps the next switch a config change. Free basics: config out of code, a feature flag, and a re-test of tool calls and JSON.

01

Point your OpenAI client at Lyceum's serverless API

Lyceum's serverless inference serves open models such as Kimi, GLM, DeepSeek and Qwen through one OpenAI-compatible API, billed per token with no base fee. In the OpenAI client you already use, you change three things: the base URL (https://api.lyceum.technology/openai/v1), the API key and the model ID. Lyceum's docs say streaming, tool calling and usage accounting then work the same, and serverless models run in Paris and Finland.

Good if your app already calls the OpenAI SDK and you want to switch this week

Skip if you depend on a closed model that only its own vendor serves

Lyceum · Lyceum Docs

Tool
Cost€
EffortLow
HelpsToday
02

Move steady traffic to a Lyceum dedicated endpoint later

Once your traffic is steady all day, Lyceum can reserve GPUs for a dedicated endpoint, with the model configuration and commercial terms agreed per contract. You call it through the same OpenAI-compatible API as serverless, so the code you changed for the switch stays as it is.

Good if your token volume is high and even across the day

Skip if your traffic comes in bursts with quiet hours

Lyceum

Tool
Cost€€€
EffortMedium
HelpsThis month
03

Put an open-source gateway in front of your providers

LiteLLM is an open-source library that gives you one interface to call over 100 LLMs, including OpenAI and Anthropic, in the OpenAI format. Your code talks to LiteLLM, and the output format stays the same whichever provider answers. It also has built-in retry and fallback logic across providers, so the next switch is a config change.

Good if you expect to use or compare more than one provider

Skip if one OpenAI-compatible provider covers everything you need

LiteLLM Docs

Tool
CostFree
EffortMedium
HelpsThis week
04

Move the base URL, key and model name out of your code

The Twelve-Factor App calls for strict separation of config from code, and counts credentials and handles to backing services as config, stored in environment variables. Put the provider's base URL, API key and model ID there, and keep your prompts in their own files. Then a switch is a new value, not a code change.

Good if the provider URL or model name is hard-coded in several places

The Twelve-Factor App

Do it yourself
CostFree
EffortLow
HelpsToday
05

Run the old and new provider side by side behind a flag

Wrap the provider choice in a feature flag. Microsoft describes feature flags as a way to turn functionality on or off, target it to specific users or roll it out gradually, all without redeploying your application. Start with your own team, then a small share of users, and keep the old provider one switch away.

Good if you want to roll back in seconds if the new provider misbehaves

Microsoft Learn

Do it yourself
CostFree
EffortMedium
HelpsThis week
06

Re-test tool calling and JSON output on the new model

A compatible API does not mean every model handles tools and JSON the same way. Even at OpenAI, Structured Outputs work only on newer models, and older ones use JSON mode, which ensures valid JSON but not that it matches your schema. Run every tool and every JSON schema your app uses against the new model and check the fields your code reads.

Good if your app parses JSON or calls tools from the model's answer

Skip if your app only shows plain text to users

OpenAI

Do it yourself
CostFree
EffortMedium
HelpsThis week
07

Compare old and new answers on real requests before you switch

Pull a set of real requests from your logs and write down what a good answer looks like for each. OpenAI warns against test sets that do not reproduce your production traffic, and Anthropic advises more test cases with automated grading over a few graded by hand. Send the set to both providers and compare before you move users.

Good if you have logs of what users send today

OpenAI · Claude Platform Docs

Do it yourself
CostFree
EffortMedium
HelpsThis week

When it's bigger than a quick fix

Bring in an engineer who has run a provider migration when your app relies on many tools, strict JSON schemas or long agent runs, or when the new model's answers keep failing your test set. OpenAI's guide says to calibrate automated checks against human judgment, which takes someone who knows your product.

OpenAI

Questions people ask

Can I use the OpenAI SDK with another provider?

Yes, if the provider offers an OpenAI-compatible API. You set its base URL, an API key and a model ID in the client you already have.

What do I change in my code to switch LLM providers?

With an OpenAI-compatible provider, usually only the base URL, the API key and the model ID. Keep those in environment variables so the switch needs no code change.

Does tool calling work the same on every model?

Not always. Even at OpenAI, only newer models keep JSON output to your schema, so test every tool and JSON schema your app uses on the new model.

What is an LLM gateway?

A layer between your code and the providers, such as the open-source LiteLLM, that calls over 100 LLMs through one interface in the OpenAI format, with retries and fallbacks.

How do I switch without downtime?

Put the provider choice behind a feature flag, start with a small share of users and keep the old provider one switch away until the new one holds.

Sources

  1. Lyceum: Serverless and dedicated inference
  2. Lyceum Docs: Serverless Inference
  3. LiteLLM Docs: Getting Started
  4. The Twelve-Factor App: III. Config
  5. Microsoft Learn: Understand feature management using Azure App Configuration
  6. OpenAI: Structured model outputs
  7. OpenAI: Evaluation best practices
  8. Claude Platform Docs: Define success criteria and build evaluations