import { generateText } from'ai';
prompt:'Explain AI Gateway in one sentence.',
});
const { text } =awaitgenerateText({
console.log(text);
model:'openai/gpt-6-astra',
Centralize multi-provider AI operations
Route a model across healthy providers and configure ordered provider and model fallbacks.
Requirement
Call AI Gateway from any environment with the AI SDK, OpenAI Chat Completions, OpenAI Responses API, Anthropic Messages, a supported coding agent, or a framework integration.
Request logging
all plans. Your use of each AI provider is subject to their terms listed on each model's page and subject to Vercel's
AI Product Terms.
How AI Gateway handles it
Authenticate your application once, then use AI Gateway system credentials or your own provider accounts through BYOK.
Centralized credentials
Use AI Gateway when you want these controls without operating your own proxy, database, and routing control plane:
Provider failover
Inspect each request's model, provider attempts, latency, token usage, status, and cost in request logs.
Spending controls
Set budgets for a team, project, API key, or team member. AI Gateway rejects new system-credential requests after an applicable budget is exceeded.
Budgets cover spend billed through AI Gateway system credentials. BYOK spend is metered separately and does not count toward those limits. If a BYOK request fails, AI Gateway can fall back to system credentials. Review the BYOK behavior and soft-cap budget semantics when strict provider-account use or zero-overshoot limits are requirements.
Choose how to start
Previous
Cross-link map: Vercel AI Gateway: Models, Routing, and Observability (/docs/ai-gateway)From the Vercel docs graph (built 2026-09-21T05:26:59.511Z), spanning vercel.com docs + KB, nextjs.org, ai-sdk.dev, and other Vercel documentation sites. Full graph as JSON: https://vercel.com/docs/graph.jsonSemantically closest pagesAI Gateway FAQ — Answers to common questions about AI Gateway, including request errors, pricing and markup, SDK and API compatibility, mGetting Started with AI Gateway — Set up AI Gateway with a coding agent, route the agent through AI Gateway, or make your first request with cURL, TypeScrAI Gateway: Production-ready reliability for your AI appsXcode with AI Gateway — Connect Xcode's AI chat to AI Gateway through the Chat Completions API. Configure the provider, API key, and models in XAI Gateway Pricing — Understand AI Gateway token pricing, free and paid credits, BYOK costs, add-on charges, and payment fees. Manage creditThis page links to (27)AI Gateway Authentication and BYOK — Authenticate AI Gateway requests with API keys or OIDC tokens, and configure bring your own key \(BYOK\) credentials forAI Gateway API Keys — Create, view, and delete AI Gateway API keys, and set each key's budget and spend attribution, from the dashboard, CLI,Bring Your Own Key \(BYOK\) to AI Gateway — Learn how to configure your own provider keys with AI Gateway.AI Gateway OIDC Authentication — Authenticate AI Gateway requests from Vercel deployments with OIDC tokens. Configure the AI SDK or send bearer tokens diCoding Agents and Chat Platforms with AI Gateway — Connect coding agents and chat platforms to AI Gateway. Configure Claude Code, Codex, Chatbox, Open WebUI, and more.AI Gateway Ecosystem and Integrations — Connect frameworks, coding tools, and billing integrations to AI Gateway. Configure app attribution and explore integratAI Gateway Framework Integrations — Connect LangChain, LiteLLM, LlamaIndex, Mastra, Pydantic AI, TanStack AI, and other frameworks to Vercel AI Gateway withAI Gateway FAQ — Answers to common questions about AI Gateway, including request errors, pricing and markup, SDK and API compatibility, mGetting Started with AI Gateway — Set up AI Gateway with a coding agent, route the agent through AI Gateway, or make your first request with cURL, TypeScrMigrate to AI Gateway Using Your Coding Agent — Move your app's model calls to Vercel AI Gateway with a single coding-agent prompt, whatever provider or SDK you use todAI Gateway Inputs and Tools — Send images, PDFs, audio, and video to AI Gateway models, and connect models to application functions with tool use.AI Gateway Model Modalities — The inputs and outputs AI Gateway models work with: text, image, and video generation, speech to text, text to speech, rAI Gateway Models and Providers — Choose AI Gateway models and providers. Configure routing, fallbacks, timeouts, prompt caching, reasoning, and web searcAI Gateway Model Fallbacks — Configure AI Gateway model fallbacks to try backup models when the primary model is unavailable. Set fallback order andAI Gateway Provider Filtering, Ordering, and Sorting — Control AI Gateway provider routing with order, only, and sort. Set preferences, restrict providers, and rank them by coAI Gateway Observability and Spend — Monitor AI Gateway requests and control costs with logs, generation lookup, custom reporting, budgets, and OpenTelemetryAI Gateway Budgets and Spend Limits — Cap AI Gateway spend for your team, a project, an individual API key, or a team member with budgets, refresh periods, spAI Gateway Request Logs — Search, filter, and follow individual AI Gateway requests, inspect provider routing for one request, and export the resuAI Gateway Pricing — Understand AI Gateway token pricing, free and paid credits, BYOK costs, add-on charges, and payment fees. Manage creditAI Gateway Rate Limits — Learn how AI Gateway rate limits work on the free and paid tiers, what the 429 response looks like, and how to retry a rAI Gateway SDKs and APIs — Connect to AI Gateway with the AI SDK, Python, REST, or compatible OpenAI, Anthropic Messages, OpenResponses, and CohereAI SDK with AI Gateway — Build AI-powered TypeScript applications using the AI SDK with AI Gateway for unified access to 200+ models.Anthropic Messages API with AI Gateway — Use the Anthropic Messages API with AI Gateway. Configure authentication and send requests with streaming, tools, imagesOpenAI Chat Completions API with AI Gateway — Use OpenAI SDKs with the AI Gateway Chat Completions API. Configure the base URL and authentication for chat, streaming,OpenAI Responses API with AI Gateway — Use the OpenAI Responses API with AI Gateway to generate text, call tools, stream tokens, and more across any supportedAI Gateway Security and Compliance — AI Gateway data privacy and governance controls: zero data retention, prompt training policies, and provider allowlists.Build AI agents with AI Gateway and AI SDK — Build AI agents on Vercel with AI Gateway and AI SDK, then make them reliable, capable, and durable with Sandbox, Chat SPages that link here (163)By site: ai-sdk (1) · chat-sdk (1) · eve (3) · vercel-changelog (80) · vercel-kb (38) · vercel-web (9) · workflow (1) · vercel-docs (30)From ai-sdkAI GatewayFrom chat-sdkTanStack AI — Feed thread history into TanStack AI's chat() and give it Chat SDK tools, with no runtime dependency on @tanstack/ai.From eveAgent configuration (agent.ts) — Configure an eve agent's model, reasoning effort, compaction, limits, and runtime behavior in agent.ts.Deployment — Choose a deployment strategy and prepare an eve agent for production.Deploy to Vercel — Deploy an eve agent with Vercel Workflow, Sandbox, Cron, and project credentials.From vercel-changelogAI Gateway and one-click deploys now available on TRAEAI Gateway is now in Beta Routing rules now available on AI GatewayAuto-recharge available in AI GatewayClaude Opus 4.1 is now supported in Vercel AI GatewayClaude Fable 5 now available on AI GatewayClaude Haiku 4.5 now available in Vercel AI GatewayClaude Opus 4.5 now available in Vercel AI GatewayUse Claude Opus 4.6 on AI GatewayClaude Sonnet 4.6 is live on AI GatewayClaude Sonnet 4 now supports 1M token context in Vercel AI GatewayDeepSeek models now available via Azure on AI GatewayDeepSeek V3.2 models now available in Vercel AI GatewayDeepSeek V4 Flash now runs updated weights on AI GatewayDeepseek V4 on AI GatewayDeepSeek V4 Pro now runs updated weights on AI GatewayGemini 3.1 Flash Lite is now on AI GatewayGemini 3.1 Pro is live on AI GatewayGemini 3.5 Flash on AI GatewayGemini 3 Flash is now available on the Vercel AI GatewayGemini 3 Pro now available in Vercel AI GatewayGemma 4 on AI GatewayGLM-4.7 available on Vercel AI GatewayGLM 5.2 now available on AI GatewayGLM-5 is live on AI GatewayGLM 5.1 on AI GatewayGLM 5V Turbo on AI GatewayGPT 5.1 Codex Max now available on Vercel AI GatewayGPT 5.1 Codex models now available in Vercel AI GatewayGPT 5.1 models now available in Vercel AI GatewayGPT 5.2 Codex now available on Vercel AI GatewayGPT 5.2 models now available on Vercel AI GatewayGPT 5.3 Chat is now on AI GatewayGPT 5.3 Codex is now on AI GatewayGPT 5.4 is now on AI GatewayGPT-5, GPT-5-mini, and GPT-5-nano are now available in Vercel AI GatewayGPT 5.5 on AI GatewayGPT Image 2 on AI Gatewaygpt-oss-20b and gpt-oss-120b are now supported in Vercel AI GatewayGrok 4.1 Fast models now available on Vercel AI GatewayTry Grok 4.20 on AI GatewayGrok 4.3 on AI GatewayGrok Build 0.1 now available on Vercel AI GatewayGrok Imagine Video 1.5 on AI GatewayKimi K2.5 is live on AI GatewayKimi K2.7 Code now available on AI GatewayKimi K2.6 on AI GatewayLongCat-Flash Chat model is now supported in Vercel AI GatewayInception Mercury 2 is live on AI GatewayMiniMax M2.1 now live on Vercel AI GatewayMiniMax M2 now available for free in Vercel AI GatewayMiniMax M2.7 is live on AI GatewayMiniMax M3 on AI GatewayMistral Large 3 now available on Vercel AI GatewayModel fallbacks now available in Vercel AI GatewayMoonshot AI's Kimi K2 model is now supported in Vercel AI GatewayMoonshot AI's Kimi K2 Thinking models are now available on Vercel AI GatewayMoonshot AI's Kimi K2 0905 model is now supported in Vercel AI GatewayNano Banana 2 is live on AI GatewayNemotron 3 Ultra now available on AI GatewayNova 2 Lite now available on Vercel AI GatewayOpenAI's GPT-OSS-Safeguard-20B now available in Vercel AI GatewayOpus 4.8 on AI GatewayClaude Opus 4.7 on AI GatewayQwen 3.5 Plus is on AI GatewayQwen 3.7 Max now available on Vercel AI GatewayQwen 3.7 Plus now available on AI GatewayQwen 3 Max Thinking now available on AI GatewayQwen 3.6 Plus on AI GatewayQwen3-Coder is now supported in Vercel AI GatewayQwen3-Next models are now supported in Vercel AI GatewayRecraft image models now on AI GatewayRecraft V4 on AI GatewayRun Terminal-Bench and other Harbor evals on Vercel SandboxTrinity Large Preview is on AI GatewayTrinity Mini model now available in Vercel AI GatewayUse GPT 5.4 Mini and Nano on AI GatewayUse MiniMax M2.5 on AI GatewayVercel MCP now supports purchasesZ.ai's GLM-4.5 and GLM-4.5 Air are now supported in Vercel AI GatewayFrom vercel-kbDurable agent approval workflows on Vercel — How enterprise architects choose a stack and decide where to run durable, human-in-the-loop agent approval workflows onHow to architect an AI evaluation dashboard on Vercel — Map eval orchestration, traces, and run storage to AI Gateway, Observability, and Marketplace Postgres, and learn when sBuild your own Slackbot with Vercel Connect — Learn how to build your very own Slackbot with Chat SDK and AI SDK. Vercel Connect supplies runtime Slack tokens and forBuild an AI Chat Agent with Weather API Tool Calling — Build an intelligent conversational agent that fetches real-time weather data using the AI SDK, tool calling, and a backBuild an agent with Vercel and Flue — Build and deploy an agent with Flue, Vercel Sandbox, and AI GatewayBuilding an AI chat app with RAG and source citations on Vercel — A production stack for AI chat with retrieval, reranking, source citations, and background ingestion on Vercel using NexBuilding community moderation agents using AI SDK — Learn how to build an AI-powered community moderation agent with Next.js, the AI SDK, and AI Gateway.Cost-aware model routing through AI Gateway — Route easy requests to a cheap model and escalate only hard ones to a frontier model through one AI Gateway endpoint, wiBuild a daily digest bot with Chat SDK and Workflow SDK — Build a daily digest bot that posts a daily digest of GitHub stats to Slack. Learn how to use Vercel Connect to set up SDraft content in your voice from Slack with eve — Deploy the eve content agent template, a Slack bot that drafts blog posts, LinkedIn posts, release notes, and newsletterManage your Sanity project from Slack with eve — A Slack-based Sanity copilot built on eve. It queries and edits content with GROQ, shapes schemas, manages releases, andBuild your first Slack agent with eve — Deploy the eve Slack agent template: a starter Slack bot built on the eve framework with an example tool and skill.Build a software factory with eve — Foreman, a software factory built on eve. It turns GitHub and Linear work items into reviewed draft pull requests througShip social posts from Slack with eve and Typefully — A Slack-based social media agent built on eve. It drafts posts and threads for X, LinkedIn, Threads, Bluesky, and MastodBuild a GitHub agent with Vercel Connect — Build a GitHub agent that helps your team work through issues and PRs. Chat SDK handles the interactivity and AI SDK runHow I use OpenCode with Vercel AI Gateway to build features fast — How to route different AI models to different coding tasks automatically, cutting token costs by ~70% without losing quaBuilding AI apps on Vercel: an overview — Learn the key AI concepts and tools for building and scaling AI apps.How to build an AI agent for Slack with Chat SDK and AI SDK — Build a Slack AI agent using Chat SDK, AI SDK's ToolLoopAgent, and Vercel AI Gateway. Covers project setup, tool definitHow to build your own AI model router — Build an AI model router with Vercel AI Gateway. Keep routing, key, and retention decisions in your code while the gatewHow to execute AI-generated code safely with Vercel Sandbox — Learn how to run code generated by AI models in an isolated sandbox environment.How to run a multi-step research agent on Vercel — An end-to-end architecture for production research agents on Vercel using Sandbox, Workflows, and AI Gateway with isolatBuild a Linear agent with Vercel Connect — Build a native Linear Agent that helps your team manage issues. Mention it on any issue and it responds in real time, poRun a marketing team from Slack with eve — Team of five marketing agents built on eve. The lead routes work to specialists that write long-form into Notion, queueHow to route your coding agent spend through AI Gateway — Point Claude Code, Codex, Cursor, and every other harness on your machine at AI Gateway with one CLI command, on a budgeRun AI prompts in your GitHub Actions with the Vercel AI Action — Use the vercel/ai-action@v2 GitHub Action to call the AI Gateway from a workflow. Generate text or structured JSON, setRun Terminal-Bench and any Harbor benchmark on Vercel Sandbox — Run Terminal-Bench, SWE-bench, and any Harbor benchmark on Vercel Sandbox. Each trial executes in an isolated FirecrackeSafely running AI generated code in your Next.js application — How to execute untrusted, AI‑generated code from a Next.js app using Vercel Sandbox, an isolated, ephemeral environment.Running OpenClaw in Vercel Sandbox — This guide walks you through setting up OpenClaw inside a Vercel Sandbox and configuring the WhatsApp channel.Running OpenCode securely with the Vercel Sandbox — Run OpenCode in an isolated Vercel Sandbox MicroVM with controlled egress, using the SDK to restrict network access so tInvestigate GitHub issues with \HarnessAgent\\ and Vercel Sandbox — Use HarnessAgent to run coding agent harnesses like Claude Code or Codex against untrusted code inside Vercel Sandbox. RHow to build a Slack bot that manages files in Vercel Blob — Build a Slack bot using Chat SDK, AI SDK, and Files SDK that can list, read, upload, and delete files in Vercel Blob thrUsing TanStack AI with Vercel AI Gateway — Connect TanStack AI to Vercel AI Gateway with the @tanstack/ai-vercel-gateway adapter to stream chat, route across proviVercel vs Akamai — A detailed guide to Vercel vs Akamai: compute models, AI infrastructure, framework support, media streaming, CDN capabilVercel vs Fastly — A detailed guide to Vercel vs Fastly: full-stack application platform vs edge infrastructure layer, covering framework sVercel vs Netlify — A detailed guide to Vercel vs Netlify: runtimes, compute architecture, AI infrastructure, security, and when to choose eVercel vs Northflank — A detailed guide to Vercel vs Northflank: Fluid compute, CDN and caching, container image functions, security defaults,Vercel vs Railway — A detailed guide to Vercel vs Railway: serverless vs always-on containers, container images via Dockerfile.vercel, frameVercel vs Render — A detailed guide to Vercel vs Render: compute models, AI infrastructure, Docker and container image support, backgroundFrom vercel-webAgentic InfrastructureIntroducing the AI GatewayAI SDK 5Anyone can build agents, but it takes a platform to run themInside the Vercel intern experienceIntroducing eveKeeping community human while scaling with agentsv0: vibe coding, securelyZero Data Retention on AI GatewayFrom workflowBuilding Durable AI Agents — Convert a basic AI chat app into a durable, resumable agent using Workflow SDK.From vercel-docsTools — Available tools in Vercel MCP for searching docs, managing teams, projects, deployments, Web Analytics, runtime logs andAI Gateway Framework Integrations — Connect LangChain, LiteLLM, LlamaIndex, Mastra, Pydantic AI, TanStack AI, and other frameworks to Vercel AI Gateway withLangChain with AI Gateway — Learn how to integrate Vercel AI Gateway with LangChain to access multiple AI models through a unified interface.Langfuse with AI Gateway — Trace and monitor AI Gateway requests with Langfuse. Configure an OpenAI client and wrap it with observeOpenAI to log moLiteLLM with AI Gateway — Learn how to integrate Vercel AI Gateway with LiteLLM to access multiple AI models through a unified interface.LlamaIndex with AI Gateway — Learn how to integrate Vercel AI Gateway with LlamaIndex to access multiple AI models through a unified interface.Mastra with AI Gateway — Learn how to integrate Vercel AI Gateway with Mastra to access multiple AI models through a unified interface.Pydantic AI with AI Gateway — Learn how to integrate Vercel AI Gateway with Pydantic AI to access multiple AI models through a unified interface.TanStack AI with AI Gateway — Connect TanStack AI to Vercel AI Gateway with the official adapter to authenticate requests and stream responses from AIWordPress with AI Gateway — Learn how to integrate Vercel AI Gateway with WordPress to let your plugins access multiple AI models.AI Gateway Image Generation — Generate and edit images using AI models through Vercel AI Gateway with support for multiple providers and modalities.AI Gateway Routing Rules — Define team-wide rules that rewrite requests from one model to another or deny specific models in AI Gateway.AI Gateway Discounts — Discounts on AI Gateway token spend: models already priced below list for every team, plus custom volume discounts withVercel CLI Overview — Learn how to use the Vercel command-line interface \(CLI\) to manage and configure your Vercel Projects from the commandvercel ai-gateway — Manage AI Gateway resources from the Vercel CLI: API keys, budgets, routing rules, virtual models, models, leaderboards,TanStack AI — Connect a TanStack AI app to OAuth-protected MCP servers with Vercel Connect, handle user consent, and manage MCP clienteve — Build and deploy durable backend AI agents with eve, an open-source, filesystem-first framework.Concepts — Learn how eve agents, sessions, channels, tools, skills, connections, and sandboxes fit together.Glossary — Learn about the terms and concepts used in Vercel's products and documentation.MCP Integrations — Connect AI SDK, TanStack AI, and eve applications to MCP servers to discover and call tools.AI SDK with MCP — Connect the AI SDK to an MCP server on Vercel, discover its tools, and call them with models served through AI Gateway.TanStack AI with MCP — Connect TanStack AI to a Model Context Protocol server on Vercel and call its tools with models served through AI GatewaProducts — Browse Vercel products for building, deploying, securing, observing, and scaling web applications.Projects overview — A project is where you deploy and operate frontend apps, APIs, backends, containers, and agent workloads on Vercel.Ecosystem — Use Vercel Sandbox with the agent frameworks, model SDKs, and coding agents you already work with.Anthropic SDK — Use Anthropic tool use with AI Gateway to execute model-generated code in an isolated Vercel Sandbox.Harbor and Terminal-Bench — Run Terminal-Bench and any other Harbor Hub dataset on Vercel Sandbox, with each trial in its own isolated Firecracker mLangChain — Give a LangChain agent a tool that executes model-generated code in an isolated Vercel Sandbox, with models served by AIOpenAI SDK — Use OpenAI function calling with AI Gateway to execute model-generated code in an isolated Vercel Sandbox.Spend Management — Learn how to get notified about your account spend and configure a webhook.
Start / Production Checklist
Was this helpful?
Next
Explore chat platforms and ecosystem integrations, learn how to handle 429 responses, or see the AI Gateway FAQ for common questions about model availability, pricing, and request errors.