Vercel AI Gateway and OpenRouter each provide a unified API for routing requests to multiple model providers. AI Gateway connects Vercel deployment identity with project usage and budgets. OpenRouter offers a broader provider catalog, provider-pricing filters, and shared routing presets.
An AI gateway provides an application with a single integration point to those providers. To choose between these two, compare the models your application needs, how the team attributes spend, and which routing policies it must enforce. Both support provider preferences, fallback models, and requests from infrastructure outside Vercel.
Copy link to headingHow to compare AI Gateway and OpenRouter
Start with the model and serving provider, then follow the request through routing, billing, and reporting. A shared API reduces integration work, but it does not make the gateways' policies or accounting interchangeable.
Copy link to headingAt a glance
See the published AI Gateway pricing and OpenRouter pricing pages for the latest pricing and plan details.
Copy link to headingTrace provider selection and fallback behavior
Both gateways can try another provider or a fallback model when a request fails. In AI Gateway, request-level provider preferences and fallback models sit in providerOptions.gateway. OpenRouter uses a provider object for provider selection and a models array for model fallbacks.
By default, OpenRouter selects a provider for each request using price-weighted load balancing that also considers recent availability. Callers can change the provider order, exclude providers, or sort candidates. Latency and throughput thresholds express preferences rather than guaranteed performance levels.
After a fallback, inspect which model served the request. OpenRouter returns it in the response's model field. AI Gateway records its model and provider attempts in response metadata and request logs. Applications still need to handle requests that fail after all eligible routes have been tried.
In a week-long production A/B test against its previous AI router, Cline reported a 43.8% reduction in API error rate and 10% to 14% lower 99th-percentile streaming latency across its most-used models after routing traffic through AI Gateway.
Copy link to headingSeparate inference prices from gateway fees
Both gateways pass through provider token prices without markup. OpenRouter charges its platform fee when teams buy credits. AI Gateway adds no token platform fee, though optional capabilities may add charges.
With BYOK, the provider bills inference under your agreement. AI Gateway adds no BYOK fee but requires purchased AI Gateway Credits. If a request using your credentials fails, AI Gateway can retry with system credentials and charge that fallback against the credit balance.
OpenRouter's Standard and Business plans include a monthly allowance of list-price BYOK inference without an OpenRouter fee. Above that allowance, OpenRouter charges 5% of what the same request would cost at list price on OpenRouter, deducted from your credits. Enterprise allowances are custom.
OpenRouter's max_price field filters providers by their published rates. For token-priced requests, it limits accepted input and output token rates. It does not set a total dollar cap on the request, which still depends on token usage.
Copy link to headingAttribute spend to projects, features, and users
AI Gateway attributes requests authenticated through OpenID Connect (OIDC) to the Vercel project. Requests made with an AI Gateway API key use key-level attribution instead, even when the key is used in that project’s deployment. A team that needs project budgets should account for that distinction when configuring authentication.
A project report shows feature costs when each project corresponds to a feature. Within a single project, Custom Reporting (which requires Pro or Enterprise) provides fine-grained attribution through user IDs and request labels.
OpenRouter's Activity reporting includes model, provider, API key, app, and user dimensions, with organization-member filtering and CSV or PDF export. It does not inherit Vercel's project structure. To distinguish between two features within a single application, use separate API keys or attach feature labels to Broadcast traces.
Copy link to headingDecide where routing policies live
AI Gateway supports routing options in each request and team-wide model rewrite and deny rules. The rules can change or block a model without requiring every caller to redeploy.
OpenRouter's shared presets let callers reuse model and routing configurations. Callers must reference a preset, and matching request parameters can override its values. Workspace guardrails enforce access and data policies. Use enforcement controls for mandatory policies rather than relying on every caller to select the right preset.
Copy link to headingCheck retention and processing-location requirements
Both products can restrict requests to providers covered by zero data retention agreements. AI Gateway supports per-request zero data retention on Pro and Enterprise. OpenRouter supports the provider.zdr flag.
Their regional controls cover different parts of a request. AI Gateway offers regional inference for eligible models in the United States, the European Union, Australia, and Japan. That selects where the provider runs inference and where it stores request data, if any is retained. AI Gateway processing can still occur in another Vercel region.
OpenRouter's European and US regional domains also localize prompt and completion processing at the gateway for Business and Enterprise. Its European region includes the European Union and European Economic Area, the United Kingdom, and Switzerland. Account and operational records are handled separately, and teams control the regions for their own BYOK deployments and observability destinations.
Check the model, provider agreement, and processing boundaries before relying on either product for a residency requirement.
Copy link to headingHow to evaluate AI Gateway for Vercel projects
AI Gateway provides one endpoint and credentials for models from multiple providers. Its catalog includes text, image, video, speech, and embedding models. It handles routing, failover, request logging, and budgets across all Vercel plans, with specific requirements for certain capabilities.
Vercel deployments can authenticate through OIDC tokens without storing an AI Gateway API key. That connects the request to a project and removes a credential the team would otherwise store and rotate. Applications elsewhere can use a server-side AI_GATEWAY_API_KEY with API-key budgets and team-wide routing rules.
The AI SDK includes AI Gateway support. Supported creator/model strings use it by default unless the application overrides the global provider. That removes the need for a separate AI Gateway provider package.
Check the current model list for each required model and serving provider. AI Gateway's provider catalog is smaller than OpenRouter's. Free credits cover a subset of models; purchased credits unlock the full available catalog and higher rate limits. Per-request zero data retention and Trace Drains require Pro or Enterprise, and some optional capabilities carry usage charges.
Copy link to headingHow to evaluate OpenRouter for provider choice
OpenRouter routes requests through one API and a credit balance. Paid plans cover the full catalog, while the free plan provides a limited set of free models. The catalog includes specialist models outside the major labs, so compare the specific model-provider combinations your application will use.
Provider exclusions, rate filters, and reusable presets give teams control over where requests go. Those controls apply to model evaluation and ongoing production traffic. Business and Enterprise add regional domains and workload identity federation.
Keys, logs, and budgets live in a separate account from the application's hosting account. Decide how to map applications and features to OpenRouter's reporting dimensions before moving traffic. If you use @openrouter/ai-sdk-provider, include a compatibility check when upgrading it or the AI SDK because the packages are released independently.
Copy link to headingHow to choose a gateway for your application
Test the models and serving providers the app requires with representative requests. Inspect the model that served each request, the failure path, and the account or budget that records the charge.
Copy link to headingChoose AI Gateway for Vercel identity and project attribution
Choose AI Gateway when OIDC authentication and project-level reporting remove the setup that your team would otherwise maintain. Its rewrite rules also let a team replace a model across services without coordinating releases for every caller. Confirm catalog coverage and distinguish OIDC project usage from API-key usage before setting budgets.
Copy link to headingChoose OpenRouter for its catalog and routing controls
Choose OpenRouter when it provides a required model-provider combination or when provider exclusions, rate filters, and shared presets match the team's routing needs. Account for credit-purchase fees and configure feature attribution in the reporting system the team uses.
Copy link to headingCheck migration work before moving traffic
Both gateways accept OpenAI-compatible requests, which can reduce migration work. Model IDs, provider identifiers, routing options, supported parameters, and response metadata can differ. Test those differences before switching. An existing integration with the required models and controls may not justify a migration based on catalog size or headline fees alone.
Copy link to headingHow to configure routing, budgets, and authentication in AI Gateway
Copy link to headingConfigure provider and model failover
The order array sets provider preferences for each compatible model attempted. The models array lists fallback models.
Install the ai package and configure server-side authentication through a Vercel OIDC token or AI_GATEWAY_API_KEY before running this example.
import { streamText } from 'ai';
const result = streamText({ model: 'anthropic/claude-sonnet-5.5', prompt: 'Explain the tradeoffs of server-side rendering', providerOptions: { gateway: { order: ['vertex', 'bedrock', 'anthropic'], models: ['openai/gpt-6-astra'], }, },});
for await (const chunk of result.textStream) { process.stdout.write(chunk);}The example prints the streamed response. The routing policy stays in code beside the prompt, where the team can version and test it. For BYOK credentials, per-provider timeouts can also trigger failover when a provider is slow to start responding. For streaming requests, those timeouts clear after the first stream chunk.
Copy link to headingChange or block a model without redeploying callers
If several services name the same model, replacing it can require several releases. AI Gateway's routing rules apply the change at the gateway instead.
Use the Vercel CLI to create a rewrite rule:
vercel ai-gateway rules add --type rewrite \ --source anthropic/claude-sonnet-5 \ --destination anthropic/claude-sonnet-5.5The app keeps requesting the source model while the AI Gateway serves the destination model. BYOK, fallback settings, and provider options remain in place. For a cross-provider rewrite, provider-specific options must match the destination provider.
A deny rule blocks the directly requested model with HTTP 403. Rules apply across the team, with a short propagation period for changes.
Copy link to headingAttribute spend and enforce budgets
AI Gateway checks each applicable budget before a request and rejects further requests after a limit is exceeded. Team budgets cover team spend. Project budgets apply to usage through a project's OIDC tokens. API keys have their own budgets, and keys attributed to a team member also count toward that member's budget.
The check runs at the start of a request. A request that crosses the limit can finish, so a budget is a soft cap rather than a guarantee that spending will stop at the exact amount.
API-key usage does not count toward a project budget, even when the key is used in that project's deployment. BYOK spend is metered separately and does not count toward these budget limits.
On Pro and Enterprise, the Custom Reporting API lets teams query usage by user ID and request tag. Reporting writes and queries incur additional charges. Trace Drains send OpenTelemetry traces to an external observability tool according to the drain's sampling configuration. Delivered traces and transferred data incur usage charges.
Copy link to headingAuthenticate without a stored gateway key
Vercel deployments can call the AI Gateway with their OIDC tokens. Code outside Vercel can use an AI_GATEWAY_API_KEY kept on the server. Teams can configure BYOK credentials once and reuse them across projects. The provider then bills inference under the team's agreement, while AI Gateway continues to record usage and routing data.
Confirm that the catalog covers your models, then test failure handling and spend attribution with your application's credentials. Start a new project to make your first model call, or browse the templates for an AI app starting point.
Copy link to headingFrequently asked questions
Copy link to headingCan I use AI Gateway outside Vercel?
Yes. Authenticate with an AI_GATEWAY_API_KEY kept on the server. Team-wide routing rules and applicable team, API key, and team-member budgets still apply. Project budgets require usage through the project's OIDC tokens.
Copy link to headingCan I switch from OpenRouter without rewriting my application?
For supported OpenAI-compatible requests, change the base URL to https://ai-gateway.vercel.sh/v1 and update the credentials to establish the basic connection. Check model IDs, provider identifiers, supported parameters, routing options, and response metadata before moving traffic.
Copy link to headingHow do I authenticate during local development?
Link the app to a Vercel project, then run vercel env pull to download its OIDC token into a local environment file kept out of version control. Downloaded tokens are valid for 12 hours. Run vercel env pull again when the token expires, or use a server-side AI_GATEWAY_API_KEY.
Copy link to headingDoes OpenRouter work with the AI SDK?
Yes. OpenRouter publishes @openrouter/ai-sdk-provider. Its createOpenRouter function creates a provider instance for generateText and streamText.
By default, the AI SDK routes requests with supported plain-string model IDs through AI Gateway unless the application overrides the global provider.