SunsetDiff

How to swap a deprecated model in LiteLLM, OpenRouter, the AI SDK, and LangChain

Point the model argument at the replacement id from the provider's deprecation page. LiteLLM and OpenRouter document a fallback list. The Vercel AI SDK OpenAI guide and LangChain's ChatOpenAI page document the model string, not a fallback list.

Last reviewed . Publisher: SunsetDiff.

Steps

  1. Copy the replacement id. Take it from the provider deprecation page or the SunsetDiff model page. Do not invent a short name.
  2. Change the model argument. LiteLLM uses the model string. OpenRouter uses model plus an optional models list. The AI SDK uses openai('model-id'). LangChain uses init_chat_model or the provider class model argument.
  3. Add a documented fallback. LiteLLM fallbacks and OpenRouter models are ordered backups. Leave the AI SDK and ChatOpenAI calls as a single id unless you route through one of those two.
  4. Replay one request. A new id can reject an old field. Use the pre-migration checklist.

LiteLLM

LiteLLM's completion helper tries the model argument first, then each entry in fallbacks, in order. A fallback entry is a model name or a dict of completion arguments. The first success is returned. If every entry fails, completion raises, and the message ends with All fallback attempts failed.

The strings in the sample are the ones in LiteLLM's docs. Replace them with the retired id and the replacement id. The proxy uses a different shape: model_name is the name clients send, litellm_params.model is the provider string, and router_settings.fallbacks maps one model_name to another.

Python completion fallbacks

from litellm import completion
response = completion(
    model="bad-model",
    messages=[{"role": "user", "content": "Hello"}],
    fallbacks=["gpt-6-luna", "command-nightly"],
)

Proxy config shape

router_settings:
  fallbacks:
    - gpt-6-luna:
        - gpt-6.1-sol

Sources: LiteLLM reliable completions , LiteLLM proxy fallbacks , LiteLLM proxy config , checked October 20, 2026.

OpenRouter

OpenRouter's model fallbacks guide says the models array is tried in order when the first model returns an error. Errors that trigger a fallback include context length, moderation, rate limits, and downtime. The response model field is the id that actually ran, and the price is that model's price.

With the OpenAI SDK, the guide puts the first id in model and the backups in extra_body.models. The ids below are the guide's examples, including the ~ prefix that guide uses. This page does not include an API key.

Arguments from the OpenRouter docs

model = "~openai/gpt-sol-latest"
extra_body = {
    "models": ["~anthropic/claude-sonnet-latest", "gryphe/mythomax-l2-13b"]
}
messages = [{"role": "user", "content": "What is the meaning of life?"}]

Source: OpenRouter model fallbacks , checked October 20, 2026.

Vercel AI SDK

The AI SDK OpenAI guide creates the model with openai('model-id'). The string in the docs example is gpt-6-astra. Change that string to the replacement id. generateText and streamText take that model object.

That guide does not document a fallback list. For a second model, use the LiteLLM or OpenRouter fallback above, or catch the error in your own code and call a second model id.

TypeScript

import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";

const { text } = await generateText({
  model: openai("gpt-6-astra"),
  prompt: "Hello",
});

Source: AI SDK OpenAI guide , checked October 20, 2026.

LangChain

LangChain's models page sets the id on init_chat_model or on the provider class. The documented examples include init_chat_model("gpt-5.5"), ChatOpenAI(model="gpt-5.5"), ChatAnthropic(model="claude-sonnet-4-6"), ChatGoogleGenerativeAI(model="gemini-3.7-flash"), and init_chat_model("us.anthropic.claude-sonnet-4-6", model_provider="bedrock_converse").

Azure is the deployment name, not only the OpenAI model id. The documented call passes azure_deployment. Microsoft's working-with-models page is where that deployment's version and upgrade policy are set.

The chat integrations page says routers such as OpenRouter and LiteLLM offer automatic fallbacks. It does not document a fallback list on ChatOpenAI. The samples below omit credentials. The library reads the credential you already configured.

Python

from langchain.chat_models import init_chat_model
model = init_chat_model("gpt-5.5")

Bedrock id from the LangChain docs

model = init_chat_model(
    "us.anthropic.claude-sonnet-4-6",
    model_provider="bedrock_converse",
)

Sources: LangChain models , LangChain chat integrations , Working with Azure OpenAI models , checked October 20, 2026.

Related SunsetDiff pages

All guides

Questions

Does the AI SDK openai() helper have a fallback argument?

The OpenAI guide shows openai('model-id') and does not document a fallback list. Use LiteLLM fallbacks or OpenRouter's models array when you want a documented backup.

Should I put an API key in the model config this page shows?

No. Keep the credential where the SDK already reads it. These samples only change the model id.

More guides

Deprecation alerts

We email you before models shut down. Unsubscribe anytime.

Deprecation alert signup
Providers (optional)