ai-gateway

Configure model routing, failover, and cost tracking through the Vercel AI Gateway unified API.

Updated Jul 31, 2026
One-click install
npx skills add https://github.com/AarnavBaddam/skills --skill ai-gateway-aarnavbaddam
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ai-gateway
Source: https://github.com/AarnavBaddam/skills/tree/main/ai-gateway
Command: npx skills add https://github.com/AarnavBaddam/skills --skill ai-gateway-aarnavbaddam

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ai, @ai-sdk/gateway.

What problem does it solve? Managing multiple AI providers means juggling separate SDKs, API keys, and billing dashboards, with no built-in failover when a provider goes down. This Skill provides expert guidance for routing all model calls through the Vercel AI Gateway, a single unified API with authentication, failover, and cost controls. ## Core Features & Use Cases - Unified Model Routing: Call 100+ models from OpenAI, Anthropic, Google, and others using simple provider/model slugs through one endpoint. - Failover and Provider Ordering: Configure order, only, and fallback models so requests automatically reroute when a provider is unavailable. - Cost Controls and Observability: Apply per-user rate limits, tag-based budget attribution, cache-control headers, and audit logging for production workloads. - Use Case: You are building a multi-tenant SaaS chat feature. Use this Skill to set up OIDC authentication via vercel env pull, route anthropic/claude-sonnet-4.6 with an OpenAI fallback, tag requests per feature, and enforce per-user rate limits. ## Quick Start Ask the AI to set up Vercel AI Gateway in your project with OIDC authentication and a generateText call using the openai/gpt-5.4 model slug.

Frequently Asked Questions about ai-gateway

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

FAQPage Schema
How do I route AI model calls through Vercel AI Gateway?

Pass a provider/model string like openai/gpt-5.4 to the model parameter in generateText, and the AI SDK routes it through the gateway automatically. Use the gateway() wrapper only when you need providerOptions.gateway for routing, failover, or tags.

How do I set up Vercel AI Gateway authentication?

Run vercel link, enable AI Gateway in your project settings, then run vercel env pull to provision a VERCEL_OIDC_TOKEN in .env.local. Alternatively, set AI_GATEWAY_API_KEY as a static key for CI or non-Vercel environments.

When should I use AI Gateway vs a direct provider SDK?

Use the gateway when you need failover, cost tracking, per-user rate limiting, or audit logging across providers. Use a direct provider SDK for provider-specific features like Anthropic computer use, self-hosted models, or custom HTTP transport control.

Does Vercel AI Gateway support provider failover?

Yes, configure providerOptions.gateway with order to prioritize providers, only to restrict providers, and models to specify fallback models. When a provider errors or exceeds quota, requests automatically reroute to the next option.

Why does AI Gateway return HTTP 429 or 402 errors?

HTTP 429 means a user exceeded configured rate limits; check the retry-after response header. HTTP 402 means a hard budget limit was reached; handle it by degrading gracefully with a fallback response.

Does Vercel AI Gateway charge markup on model tokens?

No, tokens are billed at exact provider list price with zero markup, whether using Vercel-managed keys or Bring Your Own Key. Every team gets $5 of free credits monthly, with pay-as-you-go top-ups beyond that.