The best AI gateway depends on who should operate it and how your application uses models. Managed services such as Vercel AI Gateway and OpenRouter provide access to multiple providers. Self-hosted gateways give your team control of the proxy, while gateways built into platforms such as Neon and Netlify connect model access to those platforms' projects and credentials.
Among paid Vercel AI Gateway teams processing at least 10 million tokens in both September and October 2026, about half changed their most-used model in October, and six in ten of those switches crossed labs. An AI gateway gives applications a shared interface across models and providers.
Copy link to headingWhat is an AI gateway?
An AI gateway routes an application's model requests through a shared interface. Depending on the gateway, it can manage credentials, choose providers, retry eligible failures, and record usage. Centralizing those controls lets several applications share a routing policy without implementing it independently.
Agent workloads make these controls relevant across repeated model calls. In April 2026, 58.9% of tokens on Vercel AI Gateway belonged to requests ending in a tool call, up from 31.6% in October 2025. The gateway handles model requests; the application owns checkpoints and recovery across the run.
Copy link to headingHow do the nine AI gateways compare?
Provider failover tries another provider for the same model. Model fallback tries a different model, whose output and API behavior the application must support. Both depend on eligible targets and the routing policy you configure.
Copy link to heading1. Vercel AI Gateway
Vercel AI Gateway is our managed gateway for accessing 400+ models from applications on any host. It retries eligible failures through other providers serving the same model by default. Model fallbacks extend recovery to other models when every eligible provider for the primary model fails.
In the production index covering traffic through April 2026, about 3.5% of requests completed after a fallback. Those requests accounted for 5.1% of tokens and 4.9% of estimated spend. Request logs record each routing attempt, including failures that a later attempt recovered.
Virtual models save a model, its fallback list, and its zero data retention setting under one ID. Teams can change that configuration without redeploying applications, and routing rules can rewrite or deny model requests across the team. The catalog also publishes rolling one-hour metrics for median and 95th-percentile time to first token and throughput by model and provider, excluding BYOK.
With the AI SDK, a model string routes through AI Gateway. Other stacks can use its OpenAI Chat Completions, OpenAI Responses, or Anthropic Messages endpoints. Vercel deployments can authenticate with OpenID Connect (OIDC), while applications elsewhere use a Gateway API key. Tailscale built its customer-facing Aperture router on AI Gateway and controls model access by tailnet identity.
Copy link to headingWhat to consider with Vercel AI Gateway
AI Gateway deletes prompts and responses after requests finish, but providers have their own retention policies. Opt-in zero data retention (ZDR) routing restricts eligible requests to providers with a ZDR commitment. Pro and Enterprise teams can enable it; Hobby teams and Pro trials need purchased credits. An active Token Pass enables per-request ZDR without meeting those team-wide requirements.
The gateway runs on Vercel's infrastructure. Private Inference lets you connect your own model endpoints, but requests still pass through AI Gateway. It therefore doesn't replace a proxy that must run inside your network. Custom provider timeouts apply only to BYOK credentials; some providers may still charge for an attempt they cannot cancel.
Requests using Vercel's provider keys are billed at provider list rates without a token markup. With bring your own key (BYOK), the provider bills inference directly. BYOK requires purchased Gateway credits and a positive balance. By default, failed requests can use Vercel's keys and spend those credits. Without fallback, successful BYOK requests cost $0.20 per 1,000, plus enabled add-on charges.
Copy link to heading2. OpenRouter
OpenRouter combines a managed gateway and model marketplace, with access to open-weight and proprietary model families through one API key. It suits applications that want to change models without managing a separate provider account for each one.
Provider failover is enabled by default. After an eligible failure, OpenRouter tries another provider serving the same model. You can set a preferred provider order while keeping other providers available for recovery. Filters narrow that pool, and fallback to a different model is opt-in.
Copy link to headingWhat to consider with OpenRouter
Every request passes through OpenRouter's managed infrastructure, so it won't satisfy a requirement to run the gateway inside your own network. Check provider eligibility and model-specific API support against your application, then compare its routing and data controls with Vercel AI Gateway. OpenRouter's current plans explain the terms for model access and BYOK.
Copy link to heading3. Cloudflare AI Gateway
Cloudflare AI Gateway suits applications that need response caching and traffic controls alongside model routing. It runs on Cloudflare's network and provides analytics, rate limiting, and data loss prevention scanning. Guardrails checks requests or responses with a Llama Guard model on Workers AI.
Cross-provider recovery depends on the routing feature you configure. Dynamic Routing combines conditions, quotas, and fallback choices in a flow. Model aliases group models under one name, while Auto Router ranks eligible models and tries another when a provider cannot serve the request. Auto Router is in public beta.
Copy link to headingWhat to consider with Cloudflare AI Gateway
Gateway-level retries and cross-provider fallback are separate controls. Dynamic Routing uses the OpenAI Chat Completions request format and requires gateway authentication and provider credentials. Check DLP coverage against the data you need to detect; accounts without a Zero Trust subscription receive two predefined profiles. Compare these controls with Vercel AI Gateway when deciding which behaviors your application needs.
If you migrate to Vercel AI Gateway, plan replacements for response caching, custom request-rate rules, and Guardrails checks in your application. Vercel tier limits and upstream provider limits do not reproduce those custom rules. Check Cloudflare's pricing for the features and logging configuration you enable.
Copy link to heading4. Neon AI Gateway
Neon AI Gateway connects model access to Neon database branches. Each branch has a gateway endpoint, and a credential works on its own branch and descendants. Applications can call it from any host over HTTPS without separate provider keys, using a Neon project in a supported region and prepaid credits.
The gateway supports OpenAI Chat Completions and provider-specific endpoints for OpenAI Responses, Anthropic Messages, and Gemini, plus an AI SDK provider package. Its model catalog lists the serving provider for each model, with most served through Databricks. This fits teams that already organize development environments around Neon branches.
Copy link to headingWhat to consider with Neon AI Gateway
Handle retries and model fallback in application code. Neon returns upstream error status codes and recommends exponential backoff for transient failures. Default account limits are 200,000 input tokens and 200,000 output tokens per minute, plus a $20 daily spend cap, though these limits can vary by account. Requests past a limit return 429; ask Neon for an increase when needed.
Databricks may retain model inputs and outputs for up to 30 days to detect abuse.
On Launch, Scale, Agent, and Enterprise plans, Neon's consumption history API reports total token usage by project or branch. It sums usage across models without costs or a per-model breakdown, so track those separately.
You can move model calls to Vercel AI Gateway while keeping the Neon database. Plan replacements for the native Gemini endpoint, branch-scoped credentials, and account limits before moving traffic.
Copy link to heading5. Netlify AI Gateway
Netlify AI Gateway supplies model credentials to applications running on Netlify. It injects provider keys and base URLs into Functions, Edge Functions, and Preview Server, where the official OpenAI, Anthropic, and Google Gen AI clients can use them. Usage shares the application's Netlify account and billing setup.
The gateway activates after the first production deployment, and credentials are available at runtime rather than during builds or prerendering. It is enabled by default on credit-based plans; Enterprise teams request access through their account manager. This fits applications that make model calls from Netlify's server-side runtime and want the platform to supply credentials.
Copy link to headingWhat to consider with Netlify AI Gateway
Netlify doesn't store prompts or outputs by default, though customers can request enhanced troubleshooting logs. For models served through OpenRouter, it routes only to providers with a ZDR policy. Supplying your own provider key opts that provider out of Netlify AI Gateway instead of routing the key through it.
Implement application retries rather than depending on undocumented cross-provider recovery. Team-wide rate limits cover every project, and the gateway has a 200k-token input limit, no request-header pass-through, and no batch inference. Check the gateway limits and current plan terms for your workload.
You can move calls to Vercel AI Gateway while the application stays on Netlify. Configure each migrated client with its own base URL and key so it doesn't use the injected credentials, and replace the credit-based rate limit before moving traffic.
Copy link to heading6. Portkey and Prisma AIRS AI Gateway
Portkey's managed product is now Prisma AIRS AI Gateway, following Palo Alto Networks' acquisition. The Portkey open-source gateway remains available under the MIT License for teams that want to run it themselves.
Prisma AIRS combines LLM, Model Context Protocol (MCP), and agent-to-agent (A2A) traffic controls. Portkey's fallback configuration accepts an ordered list of providers or models and moves to the next target when the primary fails.
Copy link to headingWhat to consider with Portkey
Choose between operating the open-source gateway and using the managed product before planning the integration. Self-hosting leaves deployment, upgrades, and monitoring with your team. Confirm which deployment and governance features the managed agreement includes. Compare Portkey and Vercel AI Gateway for the routing and governance differences, and confirm managed-service terms with Prisma AIRS.
Copy link to heading7. Kong AI Gateway
Kong AI Gateway 2.x manages LLM, MCP, and A2A traffic through entities for providers, models, MCP servers, and agents. It has a separate release schedule from Kong Gateway and replaces the older plugin-centered AI configuration. Model routing and load balancing are configured on AI Model entities.
Kong can combine tools from multiple MCP servers behind one endpoint. In 2.x, caller authentication and tool access are configured on AI MCP Server entities. This gives platform teams a shared place to govern model calls and agent traffic alongside their Kong infrastructure.
Copy link to headingWhat to consider with Kong AI Gateway
With Konnect, Kong manages the AI Gateway control plane and your team runs the data plane in its own infrastructure. The on-premises installation also requires an Enterprise license. These deployment choices differ from assuming the entire request path is a hosted service.
Kong supports rolling AI Gateway releases for one month and stable releases for six months. Choose a track that fits your upgrade schedule using the version support policy. If you're adopting Kong solely for model routing, include operating its data plane in the decision and compare the deployment requirements with Vercel AI Gateway. Check Kong's current plans for licensing terms.
Copy link to heading8. LiteLLM
LiteLLM offers a Python SDK and an OpenAI-compatible proxy for calling multiple model providers. The proxy runs on Kubernetes, Docker, or a virtual machine, giving your team control of its credentials and logs. Other languages can call the proxy API while Python applications can use the SDK directly.
The open-source core includes budgets and per-key spend tracking under the MIT License. Running the proxy inside your network doesn't keep external inference there: that also requires local model endpoints. Compare LiteLLM alternatives if operating the proxy is a larger commitment than your application needs.
Copy link to headingWhat to consider with LiteLLM
Your team owns deployment, upgrades, monitoring, and incident response. Production setups may also need Postgres for management data and Redis for shared state. Some governance capabilities, including audit logs, delegated admin roles, and certain guardrail integrations, require an Enterprise license.
LiteLLM disclosed compromised PyPI packages in March 2026 and a separate compromise of version 1.107.0 on PyPI and container registries in October. Existing users should compare the packages and image digests they ran with the affected artifacts in the March and October reports. The affected artifacts differ between the incidents; the reports provide the relevant remediation steps.
Copy link to heading9. Bifrost
Bifrost is a Go-based AI gateway with an OpenAI-compatible API and an Apache 2.0-licensed core. It includes model routing, load balancing, semantic caching, and MCP support, with custom providers and model aliases for the endpoints your applications use. You can run it in Docker, Kubernetes, or as a Go binary.
Fallbacks run after the primary attempt and its retries fail. Targets can come from an explicit list or model-catalog routing, depending on the request and version. Bifrost skips providers without credentials, so configure keys for each target.
Copy link to headingWhat to consider with Bifrost
The open-source gateway can run in your own cloud infrastructure. Bifrost Enterprise adds guardrails, cluster mode, adaptive load balancing, SAML single sign-on, audit logs, and secret-manager integrations.
For self-hosting, assign responsibility for provisioning, upgrades, and incident response. Maxim AI also advertises a managed option; confirm what its team operates before choosing that service.
Copy link to headingWhy aren't AI gateway latency benchmarks enough?
Mock-provider benchmarks measure forwarding overhead without a real inference call. In Vercel AI Gateway's first month on Fluid compute, 14,800 of roughly 16,000 runtime hours were spent waiting for providers. That aggregate shows how much work happens outside the gateway; it does not predict per-request latency.
For a streaming application, measure time to first token alongside total response time and the slowest requests. Use the same model, prompt sizes, concurrency, and client location when comparing results. Measure failed requests separately so an apparently fast response does not hide a retry or incomplete output.
Copy link to headingHow do you choose the right AI gateway?
Start with the requirements that would rule a gateway out, then test the remaining options with a representative application workload. The largest model catalog doesn't establish support for your required APIs or data controls.
Copy link to headingDecide where requests may travel
If your team must operate the gateway inside its own network, compare self-hosted options such as LiteLLM, Bifrost, and Portkey's open-source gateway. Inference remains outside that network when the gateway calls an external provider. Keeping both stages internal requires local model endpoints as well as a self-hosted proxy.
For a managed gateway, check how it handles credentials and request data. An existing Cloudflare, Neon, Netlify, or Kong deployment can influence the choice, but verify that its hosting requirements and access controls fit your application.
Copy link to headingCheck the APIs and controls your application needs
Test the exact models and API features you use, including tool calls, structured output, and streaming. OpenAI compatibility does not guarantee that every endpoint or provider-specific option is available. Confirm how to restrict providers, attribute customer usage, and enforce spending limits.
Copy link to headingExercise the failure paths
Run the same workload through each shortlisted gateway and include rate limits, timeouts, and a stream that stops after partial output. Record which attempts run, whether the fallback output still satisfies your parser, and how the application responds when all eligible targets fail. Provider restrictions and data policies can reduce the fallback routes available to a request.
Copy link to headingEstimate the full operating cost
Separate model usage from gateway fees and enabled add-ons, then include hosting and operations for a self-hosted deployment. Use expected traffic, log retention, and recovery attempts when estimating the total. Compare the resulting bill with each vendor's current terms instead of treating a starting price or free allowance as the cost of production.
Copy link to headingWhat does gateway failover leave to your application?
Gateway fallback retries one model request. It doesn't resume an agent run, so when a later step fails, the application may repeat earlier work unless it resumes from a checkpoint. Agents can cost more when recovery repeats those steps, so combine gateway fallbacks with application retries and checkpointing.
Every routing restriction narrows failover. On Vercel AI Gateway, the only filter and the team-wide provider allowlist remove failover to providers outside the list, and a ZDR request fails when no eligible provider can serve the model. Decide which requests need a restriction before you count on fallback for them.
Fallback models can format an answer differently from the primary model. Run your prompts and your output parsing against every model in a fallback list. When every target fails, the request fails, and your application still needs its own error path.
Copy link to headingBuild with Vercel AI Gateway
AI Gateway supports the AI SDK and several agent frameworks through model providers and adapters. Keep credentials on the server; model calls use Gateway credits or your provider account.
Copy link to headingFail over to another model with the AI SDK
With the AI SDK, a plain model string routes through AI Gateway. Install the package in your server-side project:
pnpm add ai@latestUse AI SDK 6 or later; AI Gateway stops accepting AI SDK 5 requests on January 8, 2027. The current release, AI SDK 7, requires Node.js 22 or later and ECMAScript modules. Set AI_GATEWAY_API_KEY in the server environment, then add the fallback configuration to model-fallbacks.ts in your existing application:
import { generateText } from 'ai';
const { text } = await generateText({ model: 'anthropic/claude-fable-5', prompt: 'Write a haiku about TypeScript.', providerOptions: { gateway: { models: ['anthropic/claude-opus-5', 'google/gemini-3.1-pro-preview'], }, },});
console.log(text);AI Gateway tries the providers that serve anthropic/claude-fable-5 first. If all of them fail, it tries anthropic/claude-opus-5, then google/gemini-3.1-pro-preview, and the response comes from the first model and provider that succeed. The response's provider metadata lists each attempt in modelAttempts. To add tools and an agent loop, follow the guide to building an agent with AI Gateway and the AI SDK.
Copy link to headingRun a durable agent with eve
eve builds an agent application around files for instructions, tools, and model configuration. Create a project with Node.js 24 or later, then authenticate with Vercel or an AI Gateway API key in the terminal UI to use Gateway models:
pnpm dlx eve@latest init my-agentThe project keeps the agent's model configuration in agent/agent.ts, and the model string there routes requests through AI Gateway:
import { defineAgent } from 'eve';
// Instructions live in agent/instructions.md.// Tools live in agent/tools/.export default defineAgent({ // This model string routes through AI Gateway. model: 'anthropic/claude-sonnet-5', reasoning: 'high',});On Vercel, eve uses the project's OIDC identity for AI Gateway and runs sessions on Vercel Workflows, which checkpoint progress between steps. If you're choosing between a file-based agent and an agent loop inside your application, compare eve, AI SDK agents, and WorkflowAgent.
Copy link to headingStream a chat response with TanStack AI
In an existing server-side JavaScript or TypeScript project running Node.js 22 or later, install TanStack AI and its AI Gateway adapter:
pnpm add @tanstack/ai @tanstack/ai-vercel-gatewaySet AI_GATEWAY_API_KEY in the server environment. The adapter reads this variable first and uses VERCEL_OIDC_TOKEN when it is absent. In index.mts, pass vercelGatewayText to chat and use a stable threadId for each conversation:
import { chat } from '@tanstack/ai';import { vercelGatewayText } from '@tanstack/ai-vercel-gateway';
const stream = chat({ adapter: vercelGatewayText('anthropic/claude-opus-5'), threadId: 'thread-1', messages: [ { role: 'user', content: 'Write a one-sentence bedtime story about a unicorn.', }, ],});
for await (const chunk of stream) { console.log(chunk);}The adapter uses the OpenAI Responses API by default. For a full setup, see the guide to using TanStack AI with Vercel AI Gateway.
Copy link to headingGive a Mastra agent a gateway model
Mastra reaches AI Gateway through the AI SDK's gateway provider. In an existing Mastra project running Node.js 22.13 or later, add the provider:
pnpm add @ai-sdk/gatewaySet AI_GATEWAY_API_KEY in the server environment. Define the agent in src/mastra/agents/assistant.ts and register it with your existing Mastra instance, following the agent setup:
import { gateway } from '@ai-sdk/gateway';import { Agent } from '@mastra/core/agent';
export const assistant = new Agent({ id: 'assistant', name: 'Assistant', instructions: 'Answer questions concisely.', model: gateway('openai/gpt-6.1-terra'),});The gateway provider reads AI_GATEWAY_API_KEY, and on Vercel it can authenticate with the deployment's OIDC token. Mastra's model router also accepts a string that starts with vercel/, such as 'vercel/openai/gpt-6.1-terra'. The router sends requests to an OpenAI-compatible endpoint, so some provider-specific features may not be available through it.
Copy link to headingSelect a gateway model in Flue
Flue includes a built-in vercel-ai-gateway provider. You need an existing Flue project with @flue/runtime and @flue/cli installed, and Node.js 22.19 or later. Choose a model with useModel() in src/agents/assistant.ts:
'use agent';
import { useModel } from '@flue/runtime';
export function Assistant() { useModel('vercel-ai-gateway/openai/gpt-6.1-sol'); return 'Answer questions clearly and concisely.';}The model specifier selects Flue's vercel-ai-gateway provider and a Gateway model ID. Set AI_GATEWAY_API_KEY in the server environment; if your Flue configuration sets a providers list, include 'vercel-ai-gateway' for server builds. Vercel OIDC authentication requires custom provider registration.
Copy link to headingFrequently asked questions
Copy link to headingWhat is the best free AI gateway?
Compare what the allowance covers before choosing a free AI gateway. Vercel AI Gateway offers a monthly credit for eligible models, while open-source gateways let you operate the proxy yourself. Hosting, inference, and ongoing operations can still incur costs; check each option's current terms for your workload.
Copy link to headingIs Vercel AI Gateway good for apps not hosted on Vercel?
Yes. An AI Gateway API key authenticates requests from any server, cloud, continuous integration (CI) pipeline, or local environment, and you need a Vercel account but no Vercel project. Supported coding agents, including Claude Code, Codex, and Cursor, can also send their requests through the gateway.
Copy link to headingWhat should you include when comparing AI gateway costs?
Include model usage, gateway charges, and any enabled logging or governance features. For self-hosted gateways, add hosting and the work required to operate them. Check how retries and fallback attempts are billed, and separate provider charges from gateway charges when you bring your own keys.
Copy link to headingHow does Cloudflare AI Gateway compare to OpenRouter?
OpenRouter combines access to multiple model families with provider failover enabled by default. Cloudflare AI Gateway adds response caching and request controls, with cross-provider recovery configured through Dynamic Routing, model aliases, or Auto Router. Choose according to the APIs and controls your application needs, then test its failure paths.
Copy link to headingWhich AI gateway is best for secure data routing?
Choose the control that matches your data requirement. Vercel AI Gateway's opt-in ZDR routing restricts eligible requests to providers with a zero data retention commitment. Availability depends on your plan, purchased credits, or an active Token Pass for per-request ZDR; see provider data controls for exclusions.
If inference must remain inside your network, use a self-hosted gateway with local model endpoints. Running the proxy yourself does not keep data internal when it sends requests to an external provider.
Copy link to headingDo all AI gateways fail over between providers by default?
No. Vercel AI Gateway and OpenRouter retry eligible failures through another provider by default. Cloudflare, Portkey, Kong, and LiteLLM require the appropriate routing or fallback configuration. Bifrost's behavior depends on whether a request names a provider or leaves selection to its model catalog. Handle retries in your application when using Neon or Netlify.
Copy link to headingOther AI gateways
Datadog AI Gateway is a managed option for teams that want model access controls and request traces in Agent Observability. It connects to your provider accounts and is in Limited Availability on supported Datadog sites. Rate limits and guardrails require enablement for your organization.
Other options include Microsoft's Azure AI Gateway, Databricks' Unity Gateway, and Agent Router, formerly Envoy AI Gateway.