published fresh until

How do I switch my app between OpenAI, Claude and Gemini easily?

Summary As of October 2026, an r/LLMDevs thread asking for the best AI gateway shows no single winner; a commenter's advice was to start with a thin wrapper and add a gateway for several providers or spend controls. Vercel's AI Gateway docs show provider-prefixed model strings and ordered fallbacks. If a stream dies midway, retry the turn, do not splice models.

Not for pointing a coding CLI at another provider, see codex-openrouter-open-weight-models

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

Your app is hard-coded to one AI provider. You want to try another model, survive an outage, or watch costs, without rewriting every call.

What the sources say

An r/LLMDevs thread (3 July 2026; many replies are vendor plugs, so read it for patterns) asked for the best AI gateway for provider switching, cost tracking, rate limiting and low config. Non-vendor opinions: one team left LiteLLM for being buggy at their scale and wanted a TypeScript option; one user tried Portkey after random LiteLLM auth errors and found model switching easy; others named OpenRouter (hosted, not self-hostable) and Vercel's gateway. A commenter wrote that most people reach for a gateway before they need one: start with a small wrapper, and add a gateway when you genuinely have several providers or need spend controls, because each hop adds latency and a dependency.

Vercel's AI Gateway provider options and model fallbacks changelog show models named as one provider-prefixed string, a models list tried in order on any error (context limits, unsupported inputs, outages) and order or only to choose providers; requests are billed for the model that succeeds. I have since read the provider-options page and the fallbacks changelog: order, only and sort choose providers, the fallback models list is tried in order until a request succeeds, any error can trigger it, and billing is for the model that completes.

On failures after a stream has started, a second r/LLMDevs thread (low signal) got a consistent set of answers: do not splice a second model into a half-finished answer; keep the partial text marked as interrupted, then retry the turn from the last committed message; give each attempt an idempotency key so a retried tool call does not send an email or charge twice; and tell the new model what already happened.

How to put it to your agent

Wrap all LLM calls behind one function with a model setting per feature (config, not code). Normalise inputs and outputs to our own types. Add a fallback list per feature, but only fall back before any text has streamed; if a stream breaks, mark the partial answer as interrupted and retry the whole turn. Give each tool call an idempotency key and store its result so a retry reuses it. Run the same 20 saved test prompts against each model before switching a feature, and log cost per call.

Mistakes to check

  • Assuming prompts behave the same on another model without testing.
  • Failing over mid-stream and mixing two answers.
  • Fallback to a model that cannot handle your tools or long inputs.
  • Adding a gateway you then have to operate.

Limits

Community opinion and docs summaries; I ran none of these tools.

Primary source

Primary sources: Vercel AI Gateway provider options and the model fallbacks changelog (Vercel). Checked: provider-prefixed model strings, order, only and sort options, fallback models tried in order on any error, billing for the successful model. The Reddit opinions about LiteLLM, Portkey and OpenRouter were not verified.

Started from a post by @LLMDevs thread starter, packaged by the editor. Original post

Subjects

More in documentation

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I switch my app between OpenAI, Claude and Gemini easily?
Summary: As of October 2026, an r/LLMDevs thread asking for the best AI gateway shows no single winner; a commenter's advice was to start with a thin wrapper and add a gateway for several providers or spend controls. Vercel's AI Gateway docs show provider-prefixed model strings and ordered fallbacks. If a stream dies midway, retry the turn, do not splice models.
Copy for agent
get the whatworks thread switch-llm-provider-without-rewriting-app-gateway-or-thin-wrapper and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread switch-llm-provider-without-rewriting-app-gateway-or-thin-wrapper
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks