Vercel AI Gateway guidance for setup, model discovery, authentication, routing, fallbacks, virtual models, evaluation models, BYOK, budgets, spend reporting, observability, compatible APIs, and coding-agent configuration. Use when adding AI Gateway to an app, migrating provider calls, choosing models or providers, centralizing model configuration, evaluating application state, debugging gateway requests, or running `vercel ai-gateway` commands.
80
93%
Does it follow best practices?
Impact
88%
1.00x1 of 3 eval scenarios. Add 2 more for a full score.
Passed
No findings from the security scan
AI Gateway exposes models from multiple providers through shared authentication, model IDs, routing, billing, and observability. Model availability, SDK APIs, CLI commands, prices, and product capabilities change frequently. Verify them from current sources before changing code.
Before implementing:
Inspect the project's language, package manager, installed AI SDK version, and existing provider integration.
Read the relevant Vercel page under https://vercel.com/docs/ai-gateway. Use the page's .md form when a tool needs Markdown.
Fetch the complete live model list. Do not construct model variants by analogy:
curl -fsSL https://ai-gateway.vercel.sh/v1/modelsIf the code uses the ai package, load the ai-sdk skill when available. Read version-matched docs under node_modules/ai/docs/ and source under node_modules/ai/src/. If the skill is not installed, use those bundled files directly.
Run vercel ai-gateway <command> --help before documenting or scripting CLI flags.
The live model endpoint and installed package take precedence over model names or SDK syntax remembered from training data.
The vercel ai-gateway command manages gateway resources for the current team. The setup subcommand connects local coding agents; the rest of the CLI covers the jobs that previously required dashboard work:
| Command | What it does |
|---|---|
api-keys create/list/inspect/remove | Create and manage AI Gateway API keys, with budgets, spend alerts, expiry, and restriction exemptions |
budgets set/list/inspect/remove | Set metered spend limits for the team, a project, a user, or an API key |
budgets set/inspect/remove --default, budgets list --defaults | Set per-scope default limits covering projects, keys, or members without a custom budget. Needs CLI 59.13+; the older budgets defaults group is deprecated |
models list / models endpoints <model> | List the model catalog and one model's provider endpoints from the CLI |
virtual-models create/list/inspect/edit/remove/restore | Manage reusable, team-scoped model configurations addressed as vmc/<slug> |
rules add/list/edit/remove | Manage routing rules; the CLI marks rules beta, so check --help before relying on them. REST CRUD exists under https://api.vercel.com/ai-gateway/rules |
setup | Configure supported coding agents; see references/coding-agents.md |
leaderboard | Explore public, anonymized usage leaderboards; rarely needed for implementation work |
Use the CLI for credential and spend management when the user is working from a terminal or in CI. Check vercel ai-gateway <command> --help for current flags before scripting; do not copy a flag list from this skill into generated code.
| User's job | Read |
|---|---|
| Ask a coding agent to make one Gateway request, or handle first-request credentials, compatible SDKs, or migration | references/setup.md |
| Provider selection, model fallbacks, caching, BYOK, or timeouts | references/routing.md |
Reusable model configuration, a vmc/<slug>, or provider options for a client that cannot send them | references/virtual-models.md |
Typed decisions (formerly evaluation) through AI SDK, POST /v1/evaluate, the OpenAI-compatible POST /v1/decisions, or the TypeSafe-compatible API | references/evaluation.md |
| Credits, budgets, reporting, Logs, or request debugging | references/spend-observability.md |
| Route Claude Code, Codex, OpenCode, Pi, or another coding agent's own model traffic through Gateway | references/coding-agents.md |
Read each relevant reference before editing. A task can require more than one.
| Existing project | Default path |
|---|---|
| JavaScript or TypeScript using AI SDK | Use a plain provider/model string with generateText, streamText, ToolLoopAgent, or the relevant modality API |
| Python using AI SDK for Python | Use ai.get_model('provider/model') and the current Python SDK docs |
| Existing OpenAI SDK | Keep the SDK and point baseURL or base_url to https://ai-gateway.vercel.sh/v1 |
| Existing Anthropic SDK | Keep the SDK and point baseURL or base_url to https://ai-gateway.vercel.sh |
| Evaluation over provider-neutral HTTP | Send Gateway's evaluation request shape to POST https://ai-gateway.vercel.sh/v1/evaluate |
| Existing TypeSafe evaluation client | Keep @typesafe-ai/sdk and point baseURL to https://ai-gateway.vercel.sh/typesafe |
| Provider-neutral HTTP | Use an AI Gateway compatible endpoint, such as Chat Completions or OpenResponses |
| Existing direct-provider AI SDK integration | Replace the provider instance with a live AI Gateway provider/model string, then remove provider credentials only after verifying the gateway path |
| Coding agent | Use vercel ai-gateway setup; inspect its help before claiming agent support. Use a Virtual Model when the agent needs reusable routing or provider options it cannot send per request |
AI Gateway also supports OpenAI Responses, Anthropic Messages, OpenResponses, Cohere Rerank, embeddings, image and video generation, speech, transcription, realtime sessions, and decisions (formerly evaluation). Modality pages under https://vercel.com/docs/ai-gateway/modalities cover each request shape, including background jobs for long-running video generation. Decisions are available through AI SDK (experimental_decide in ai 7.0.128+, or the deprecated experimental_evaluate alias on earlier AI SDK 7 releases), POST /v1/evaluate, the OpenAI-compatible POST /v1/decisions, and a TypeSafe-compatible API under /typesafe; they are not available through Chat Completions, Responses, or the Anthropic- or Cohere-compatible endpoints. Read references/evaluation.md before choosing a surface. Read the relevant modality or API page instead of translating one request shape from memory.
The current AI SDK requires Node.js 22 or later. Confirm the installed package's engines field before enforcing a version in an existing project.
import { generateText } from 'ai';
const model = process.env.AI_GATEWAY_MODEL;
if (!model) {
throw new Error('Set AI_GATEWAY_MODEL to an ID returned by /v1/models');
}
const { text } = await generateText({
model,
prompt: 'Explain the project in one paragraph.',
});
console.log(text);Honor an exact model the user or task specifies after confirming it exists. Otherwise fetch /v1/models, choose a model that fits the requested modality, capabilities, price, context window, data-retention policy, and team access, and set AI_GATEWAY_MODEL to that ID. Do not put a time-sensitive model recommendation in reusable examples.
Plain model strings route through AI Gateway. Add @ai-sdk/gateway only when the task needs its exported provider, types, model discovery, generation lookup, or spend-report helpers.
AI_GATEWAY_API_KEY and never print or commit it.VERCEL_OIDC_TOKEN; local development uses vercel link and vercel env pull..env.local. Export variables in the shell or load that file explicitly. Framework behavior may differ.Do not ask the user to paste a secret into chat, source code, a committed config file, or a command that will enter shell history unless the repository has an established secure mechanism.
Only spend credits, create keys, change budgets, change routing rules, or write coding-agent config when the user requested or approved that outward-facing action. Prefer dry runs and interactive previews when available.
provider/model strings returned by /v1/models.order controls provider preference, only restricts providers, and sort ranks providers by a supported metric.models lists fallback models after the primary model.caching: 'auto' manages provider prompt-cache markers. It is not an HTTP response cache.providerTimeouts applies to BYOK provider attempts. Streaming requests clear it at the first stream chunk; non-streaming requests time the complete response.providerOptions overrides the AI SDK top-level reasoning value entirely; the two never merge.user and tags attach reporting dimensions. They do not create per-user rate limits.providerOptions.gateway.byok and must remain secret.vmc/<slug>. A Virtual Model can pin routing and provider options server-side; settings it defines generally override the corresponding request settings, while unset settings remain request-configurable.Read references/routing.md before adding any of these fields.
vmc/<slug>..env.local loading where relevant.vercel/vercel-plugin
0db4408
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.