ai-gateway

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

Updated Aug 21, 2025
One-click install
npx skills add https://github.com/Adithiya-S/AI-Study-Companion --skill ai-gateway-adithiya-s
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ai-gateway
Source: https://github.com/Adithiya-S/AI-Study-Companion/tree/main/.agents/skills/ai-gateway
Command: npx skills add https://github.com/Adithiya-S/AI-Study-Companion --skill ai-gateway-adithiya-s

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Integrating multiple AI model providers means juggling separate API keys, model IDs, billing accounts, and failover logic. This Skill guides you through routing all model traffic through Vercel AI Gateway with correct authentication, live model discovery, spend controls, and request debugging. ## Core Features & Use Cases - Setup & Authentication: Configure AI Gateway API keys or Vercel OIDC tokens, migrate existing OpenAI or Anthropic SDK integrations by changing the base URL, and handle BYOK provider credentials correctly. - Model Discovery & Routing: Fetch the live /v1/models catalog, choose models by modality, capability, price, or data retention, and configure provider ordering, model fallbacks, prompt caching, and reasoning effort. - Spend & Observability: Set budgets at team, project, key, or user scope, query credit balances and per-generation costs, and debug requests through AI Gateway Logs. - Use Case: You want Claude Code or Codex to route its own inference through AI Gateway with a spend cap. Run vercel ai-gateway setup with a budget flag, then verify requests appear in Logs. ## Quick Start Ask the agent to add Vercel AI Gateway to my app, fetch the live model list, and make one authenticated test request with a chosen provider/model ID.

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 my application?

Create an AI Gateway API key or use Vercel OIDC, fetch the live model list from https://ai-gateway.vercel.sh/v1/models, and make a request using a provider/model ID. Existing OpenAI or Anthropic SDKs keep their request shape and only change the base URL and authentication.

How do I migrate from the OpenAI or Anthropic SDK to AI Gateway?

Keep your existing SDK and point its base URL to https://ai-gateway.vercel.sh/v1 (OpenAI) or https://ai-gateway.vercel.sh (Anthropic). Replace request authentication with an AI Gateway key, map model IDs to live gateway slugs, and remove provider credentials only after a live request succeeds.

What is the difference between AI_GATEWAY_API_KEY and BYOK provider keys?

AI_GATEWAY_API_KEY or VERCEL_OIDC_TOKEN authenticates your request to AI Gateway. BYOK provider credentials only control how the gateway authenticates to a model provider and never replace request authentication.

How do I set a budget or spending limit on AI Gateway usage?

Use the Vercel CLI: vercel ai-gateway budgets set with a scope of team, project, api-key, or user, plus a limit and refresh period. Exceeded budgets reject requests with HTTP 402 until the budget resets or the limit is raised.

Why does my AI Gateway request return 401, 402, or 429?

A 401 means missing or invalid authentication, 402 means insufficient credits or an exhausted budget, and 429 means a gateway or provider rate limit. Inspect the request in AI Gateway Logs to see each provider attempt and its status before changing routing.

Can I route Claude Code or other coding agents through AI Gateway?

Yes. Run vercel ai-gateway setup, which detects installed agents, provisions a key, previews config changes, and writes them after confirmation. Agents not covered by the CLI can be pointed manually at the coding-agent endpoint.