LiteLLM model aliases per use case to survive OpenAI model retirements
When OpenAI retires a model, the hard part is not choosing the successor; it is finding every place the old model id is pinned. The fix that stops this recurring is to give each use case its own alias on a LiteLLM proxy (address-parsing, ticket-triage) and have the application send only that alias. The model behind the alias then changes in the proxy config, with no application deploy, and the alias name documents what the call is for.
I came to this after moving a set of .NET services off a model that had an announced end-of-life date. The move itself was simple. Finding all the pins was not.
Where a model id hides in a typical service
A search for the model id across the services turned up more layers than I expected:
- Constants in code. Several services declared the model as a
const stringnext to the client that used it. - Application settings. Other calls read the model from
appsettings.json, bound to an options class with a default value in the class as well. That is two places already. - Infrastructure config. The Terraform for one service set the same setting as an environment variable on the container. In ASP.NET Core an environment variable overrides
appsettings.json, so editing the JSON file alone would have changed nothing in production. - The proxy config. One service already went through a LiteLLM proxy, and the proxy had its own entry for the model.
Any one of those left behind keeps calling the retired model until the provider starts returning errors. The environment variable is the easy one to miss, because the code and the settings file both look correct in review.
Why a successor model can change behaviour you didn't touch
The services had a small helper that decided whether a model was a reasoning model, because reasoning models reject some parameters (a non-default temperature, for example) and accept others (a reasoning effort). The helper matched on the model family prefix. The successor id happened to share the prefix, so the helper still classified it the same way and the request parameters did not change.
That was luck, not design. A successor from a different family would have flipped the classification silently, and the first sign would have been a 400 from the API on every call. If you have logic keyed on a model id, write a test that pins the classification of both the old and the new id before you switch.
How per-use-case aliases fix the pinning problem
A LiteLLM proxy maps the model field of an OpenAI-compatible request to an entry in its model_list. The model_name in that list does not have to be a real model id; it can be any name you choose. So instead of exposing gpt-4.1, expose a name per use case:
model_list:
- model_name: address-parsing
litellm_params:
model: openai/gpt-4.1
api_key: os.environ/OPENAI_API_KEY
- model_name: ticket-triage
litellm_params:
model: openai/gpt-4o-mini
api_key: os.environ/OPENAI_API_KEY
- model_name: service-default
litellm_params:
model: openai/gpt-4o-mini
api_key: os.environ/OPENAI_API_KEY
The application then sends the alias exactly where it used to send the model id. With the official OpenAI .NET SDK, the only differences from a direct call are the endpoint and the model string:
using System.ClientModel;
using OpenAI;
using OpenAI.Chat;
var client = new ChatClient(
model: "address-parsing",
credential: new ApiKeyCredential(proxyKey),
options: new OpenAIClientOptions { Endpoint = new Uri(proxyBaseUrl) });
ChatCompletion result = await client.CompleteChatAsync(
new SystemChatMessage("Split the address into street, city and postcode."),
new UserChatMessage(rawAddress));
When the next retirement notice arrives, the change is one line in the proxy config. Every caller of address-parsing moves at once, and nothing in the application, its settings or its infrastructure needs a release.
Why the alias should name the use case, not the model
It is tempting to create aliases like gpt-4-latest or small-model. Those still couple the caller to a model tier. Naming the alias after the job has three advantages:
- Use cases can diverge. Two features that share a model today may need different models tomorrow, one because a prompt was tuned on a particular model and must stay on it, the other because it wants something cheaper. With one alias each, you split them without touching code.
- Proxy logs read as features. Spend and latency per alias are spend and latency per feature, which is the question people actually ask.
- Keys can be scoped. LiteLLM virtual keys can be restricted to a list of model names. A service that only does address parsing gets a key that can only call
address-parsing, which also stops a typo from quietly reaching some other model.
What the alias hides, and how to keep it visible
The cost of an alias is that reading the code no longer tells you which model runs. I handled that in two ways.
First, the repository's own documentation names each alias and the model currently behind it. When a prompt was tuned on a specific model, the code comment says the alias exists for that reason, so nobody repoints it casually.
Second, anything that depends on the model's capabilities moves out of model-id inspection and into explicit settings. A prefix match on the model id cannot work when the application only ever sees address-parsing. Per-use-case settings such as a nullable temperature (null for models that reject one) or a reasoning effort put that decision next to the alias, where whoever changes the backing model will see it.
public sealed class AddressParsingSettings
{
public string Model { get; init; } = "address-parsing";
// Null for models that reject a temperature.
public float? Temperature { get; init; } = 0;
}
A checklist for the next model deprecation
- Search every layer for the model id: code constants, settings files, options-class defaults, infrastructure environment variables, CI variables and the proxy config.
- Check which value wins at runtime. In .NET, an environment variable beats the settings file.
- List any logic keyed on model ids and pin the old and new ids in tests before switching.
- Where a service calls the provider directly, consider routing it through the proxy as part of the same change, so this is the last time its model is pinned in code.
- Replace raw ids with per-use-case aliases, and record which model each alias points at.
Key takeaways
- A model id is usually pinned in code, settings, infrastructure and proxy config at once, and missing any one keeps the retired model in use.
- LiteLLM's
model_namecan be any name, so an alias per use case lets you change the backing model on the proxy without an application deploy. - Name aliases after the job they do, not the model tier, so features can move to different models independently and proxy metrics read per feature.
- Logic that inspects model ids breaks once callers send aliases, so move capability decisions such as temperature or reasoning effort into explicit per-use-case settings.
- Write down which model each alias points at, especially when a prompt was tuned on that model.