ai-gateway

Configure and operate Vercel AI Gateway for model routing, authentication, budgets, and observability.

Updated Sep 5, 2026
One-click install
npx skills add https://github.com/dsgalkar/dnyaneshwar_portfolio --skill ai-gateway-dsgalkar
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ai-gateway
Source: https://github.com/dsgalkar/dnyaneshwar_portfolio/tree/main/.agents/plugins/vercel/skills/ai-gateway
Command: npx skills add https://github.com/dsgalkar/dnyaneshwar_portfolio --skill ai-gateway-dsgalkar

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Routing AI model requests across multiple providers requires juggling different SDKs, API keys, model IDs, failover logic, and spend controls. This Skill guides setup and operation of Vercel AI Gateway so requests use correct authentication, live model IDs, routing rules, and budget limits without relying on outdated training-data knowledge. ## Core Features & Use Cases - Setup and Authentication: Configure AI Gateway API keys or Vercel OIDC tokens, migrate existing OpenAI or Anthropic SDK integrations by changing base URLs, and run a verified first request. - Routing and Model Selection: Fetch the live /v1/models catalog, choose models by modality, capability, price, or data retention, and configure provider ordering, model fallbacks, prompt caching, BYOK, and timeouts. - Spend and Observability: Set team, project, key, or user budgets via the vercel ai-gateway CLI, query credit balances and generation costs, and debug requests through AI Gateway Logs. - Use Case: A team migrating an existing OpenAI SDK app keeps its client, points the base URL to https://ai-gateway.vercel.sh/v1, swaps in a live provider/model ID, adds a fallback model, and caps spend with a monthly API key budget. ## Quick Start Ask the assistant to add Vercel AI Gateway to your app and make one verified request using a current model from the live model list.

Frequently Asked Questions about ai-gateway

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add Vercel AI Gateway to an existing OpenAI SDK app?

Keep your existing OpenAI SDK and change the base URL to https://ai-gateway.vercel.sh/v1, then authenticate with an AI Gateway API key or OIDC token. Model IDs become provider/model strings from the live /v1/models endpoint, and you remove direct provider credentials only after the gateway path passes a live request.

How do I configure model fallbacks with AI Gateway?

Set providerOptions.gateway.models to an ordered list of fallback model IDs; the primary model is attempted first and each fallback is tried if its providers fail. Provider policies like order or only apply to each model in the fallback chain.

What authentication does Vercel AI Gateway use?

AI Gateway requests authenticate with an AI Gateway API key (AI_GATEWAY_API_KEY) for scripts, CI, and external servers, or a Vercel OIDC token (VERCEL_OIDC_TOKEN) for Vercel deployments and linked local projects. BYOK provider credentials only control how the gateway authenticates to providers and never replace request authentication.

Can I connect Claude Code or other coding agents to AI Gateway?

Yes, run vercel ai-gateway coding-agents setup, which configures Claude Code, OpenAI Codex, OpenCode, and Pi with a previewed diff before writing. Agents not covered by the CLI can be pointed manually at https://ai-gateway.vercel.sh/coding-agent/v1 with a gateway API key.

Why does my AI Gateway request return a 402 error?

A 402 means either insufficient_funds (no positive AI Gateway Credits balance) or quota_for_entity_exceeded (a team, project, API key, or user budget is exhausted). Add credits, wait for the budget refresh period, or raise the budget limit to resolve it.

How do I set spend limits on AI Gateway usage?

Use vercel ai-gateway budgets set with a scope of team, project, api-key, or user, plus a limit and refresh period such as monthly. Budgets stack across scopes, reject requests with 402 when exhausted, and support email alerts at 50%, 75%, or 100% thresholds.