
Every team that shipped an LLM feature in 2025 learned the same lesson the hard way: your app is only as reliable as your weakest provider, and your margin is only as good as your worst routing decision. When Anthropic or OpenAI has a bad afternoon, your product has a bad afternoon. The Vercel AI Gateway answers both problems — one OpenAI-compatible endpoint, automatic failover across providers, per-model spend caps, and BYOK routing to 100-plus models. Enterprises are moving from AI assistance to AI execution: agents that run unattended, burn tokens in loops, and can’t just show an error toast when a vendor 529s.
What’s actually new with the Vercel AI Gateway
The core idea is unglamorous and exactly right: a single HTTP endpoint that speaks the OpenAI chat-completions dialect, sitting in front of every major model provider. Point your existing client at https://ai-gateway.vercel.sh/v1, pass a model string like anthropic/claude-sonnet-5 or openai/gpt-5, and the gateway handles authentication, routing, retries, and billing. If you already have code written against the OpenAI SDK, the migration is a base URL and an API key — not a rewrite.
Three capabilities that make it more than a proxy
Automatic provider failover. Models available through multiple upstream providers (Bedrock, Vertex, the first-party API, Groq, Fireworks) get an ordered fallback list, so a regional outage at one host rolls over to another without your code noticing.
BYOK — bring your own keys. You keep your negotiated enterprise rates and existing vendor relationships while still getting unified observability and routing.
Spend limits scoped per project and per model. This is the feature that lets you sleep during an agent run.
The AI SDK 5 integration
The AI SDK 5 integration goes further than the OpenAI-compatible surface. Instead of instantiating a provider object, you pass the model as a plain string and let the gateway resolve it; provider fallback is expressed declaratively in the call options. That collapses the usual “wrap every SDK in an adapter layer” chore into configuration. Teams maintaining three or four vendor SDKs with bespoke error handling for each get to delete a meaningful pile of code.
Why it matters
- Outages stop being incidents. AI Gateway failover turns a provider 503 into a routing event. Your p99 gets worse for a few seconds instead of your error rate spiking to 100 percent.
- LLM cost routing becomes a config change, not a refactor. Sending classification and extraction to a cheap fast model while reserving a frontier model for synthesis is a one-line edit when every model lives behind the same OpenAI-compatible endpoint.
- Runaway agents get a hard ceiling. Spend limits cap damage from a loop that never terminates — the failure mode that produces the five-figure invoice nobody budgeted for.
- Model evaluation gets cheap. Swapping
openai/gpt-5forgoogle/gemini-3-proin an A/B test costs a string change instead of a new dependency and a new auth flow. - BYOK LLM keys preserve your leverage. You don’t surrender enterprise pricing or data-processing agreements to get unified routing — a real blocker for regulated teams.
- One observability surface. Latency, token counts, and cost per request across every vendor in one place beats stitching together four dashboards.
How to use the Vercel AI Gateway today
-
Create a gateway API key. From your Vercel dashboard, open the AI Gateway tab and create a key. Export it locally:
export AI_GATEWAY_API_KEY="vck_your_key_here" -
Smoke-test it with curl before touching application code. If this returns a completion, your key and routing are good:
curl https://ai-gateway.vercel.sh/v1/chat/completions \ -H "Authorization: Bearer $AI_GATEWAY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "anthropic/claude-sonnet-5", "messages": [{"role": "user", "content": "Reply with OK if you can read this."}] }' -
Point an existing OpenAI client at it. No new SDK, no adapter layer:
import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.AI_GATEWAY_API_KEY, baseURL: "https://ai-gateway.vercel.sh/v1", }); const res = await client.chat.completions.create({ model: "anthropic/claude-sonnet-5", messages: [{ role: "user", content: "Summarize this changelog." }], }); console.log(res.choices[0].message.content); -
Add provider fallback with AI SDK 5. Install the SDK, then express the fallback order in the call itself. The model is a bare string — the gateway resolves it:
npm install ai@5import { generateText } from "ai"; const { text } = await generateText({ model: "anthropic/claude-sonnet-5", prompt: "Extract every action item from this transcript as JSON.", providerOptions: { gateway: { order: ["bedrock", "anthropic", "vertex"], }, }, });If Bedrock is degraded, the request rolls to the first-party Anthropic API, then to Vertex, without a try/catch in your code.
-
Route by task, not by habit. The highest-leverage cost win is refusing to send every request to your most expensive model. A small routing table does most of the work:
const MODELS = { classify: "openai/gpt-5-mini", extract: "google/gemini-3-flash", synthesize: "anthropic/claude-opus-5", }; export function modelFor(task) { return MODELS[task] ?? MODELS.classify; }Measure before you assume. Run your actual eval set against the cheap model first; if it passes, the frontier model was a habit, not a requirement.
-
Set spend limits before you ship an agent. In the AI Gateway settings, configure a per-project monthly cap and per-model caps for anything running unattended. Treat the cap as a circuit breaker, not a budget target — set it at roughly 3x expected spend so normal variance doesn’t page you, but a runaway loop dies within the hour.
-
Add your own keys. Under BYOK, paste your provider keys into the gateway. Requests then bill against your existing vendor contracts while still flowing through gateway routing and observability. Verify with a test request per provider and confirm the charge lands on your vendor invoice, not your Vercel one.
How it compares
The gateway category is crowded. The honest differentiator is not the feature checklist — most of these do failover and cost tracking — it’s how much operational surface you already run on the vendor’s platform.
| Option | Setup cost | Failover | BYOK | Best fit |
|---|---|---|---|---|
| Vercel AI Gateway | Base URL + key | Automatic, ordered provider list | Yes | Teams already deploying on Vercel or using AI SDK 5 |
| OpenRouter | Base URL + key | Yes, with provider preferences | Yes | Widest model catalog, including long-tail open models |
| LiteLLM (self-hosted) | Deploy and operate a proxy | Configurable | Yes | Teams needing full control and on-prem data paths |
| Cloudflare AI Gateway | Rewrite request URLs | Limited | Yes | Caching and analytics on an existing Cloudflare edge |
| Direct provider SDKs | One integration per vendor | Hand-rolled | N/A | Single-model apps with no switching plans |
Self-hosting LiteLLM buys maximum control and hands you an availability problem — your proxy becomes a single point of failure you have to run. That’s the correct trade for teams with strict data-residency requirements and the wrong one for a five-person startup.
What’s next
The obvious direction is routing that gets smarter than a static string. A gateway that sees every request, its latency, its cost, and (with your eval hooks) its quality sits on exactly the data needed to route dynamically — cheap model by default, escalate on low confidence. Several vendors are circling this; expect the first credible implementations to be narrow, task-specific, and worth testing before you trust them with production traffic.
Caching is the other lever. Prompt caching already exists at the provider layer, but a gateway-level semantic cache — shared across your whole fleet, invalidated on your terms — is where a lot of unrealized savings sit for RAG and support workloads with heavy query overlap. Watch for cache-hit-rate metrics showing up next to cost in gateway dashboards; that’s the signal the feature is real rather than announced.
Watch pricing pressure most closely. Gateways make model switching nearly free, which turns model choice into a live market rather than a procurement decision. That’s good for you and uncomfortable for anyone whose moat was integration friction. Build your app so the model is a config value, and you’ll capture every price cut the market produces over the next two years without shipping a single refactor.
Frequently Asked Questions
Does the Vercel AI Gateway add latency?
It adds a network hop, typically in the tens of milliseconds — negligible against multi-second LLM generations, and the gateway streams tokens through rather than buffering. If you’re building something latency-critical where tens of milliseconds matter, benchmark it against a direct call with your own traffic before committing.
What happens if the gateway itself goes down?
You’ve centralized a dependency, and you should treat that honestly. Keep one direct-provider path in your code as a break-glass fallback, gated behind an environment variable you can flip. The OpenAI-compatible endpoint makes this easy: swap the base URL back to the provider and everything else stays the same.
Do I need to use Vercel hosting?
No. The gateway is an HTTP endpoint — it works from any runtime that can make a request, including your own servers, Lambda, Cloud Run, or a Python script on a laptop. You need a Vercel account for the key and dashboard, not for hosting.
How do BYOK LLM keys affect billing?
With BYOK, token charges land on your provider invoice at your negotiated rate, and Vercel bills separately for gateway usage. Without BYOK, you pay Vercel for tokens at list-adjacent pricing. If you have meaningful committed-spend discounts with a provider, BYOK is almost always the better deal.
Does AI Gateway failover work across different models?
Failover routes across providers hosting the same model — Bedrock to first-party to Vertex, for example. Falling back to a genuinely different model is a separate decision with output-quality implications, so implement that in your application code where you can validate the result, not silently in the routing layer.
Can I use it with Python?
Yes. Point the official OpenAI Python client at the gateway base URL and it works identically:
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AI_GATEWAY_API_KEY"],
base_url="https://ai-gateway.vercel.sh/v1",
)
resp = client.chat.completions.create(
model="anthropic/claude-sonnet-5",
messages=[{"role": "user", "content": "ping"}],
)
Is this only worth it for multi-model apps?
Mostly, yes — but “single-model app” is a temporary state for almost everyone. Adopting an OpenAI-compatible endpoint now costs a base URL; retrofitting routing into a codebase with vendor SDK calls scattered across forty files costs a sprint. Adopt it while it’s cheap.
Go deeper than this article
This article covers the essentials. Our Technical & Coding eguide collection gives you the full step-by-step playbooks — prompts, workflows, and copy-paste recipes built for exactly this work.