Vercel AI Gateway
Use one hosted endpoint for hundreds of models: create a key, call it with OpenAI, Anthropic or AI SDK clients, set fallbacks and routing, cap spend with budgets, and clean up.
Scope: the hosted AI Gateway service at https://ai-gateway.vercel.sh, its API keys, OIDC, BYOK, budgets, routing rules, fallbacks, logs, privacy options and the vercel ai-gateway CLI. Out of scope: self-hosted gateways (litellm, bifrost, llm-gateway), the AI SDK itself, deploying apps on Vercel.
Work through the steps in order. Load a reference only when a step names it. Model slugs and rates change quickly, so list models live and read prices from the dashboard.
Discover first
Read-only. Nothing here prints a key.
env | cut -d= -f1 | grep -E '^(AI_GATEWAY|VERCEL|ANTHROPIC|OPENAI)' || echo "no related env vars"
command -v curl jq vercel
# Public model catalog, no key needed
curl -sS https://ai-gateway.vercel.sh/v1/models | jq -r '.data[].id' | head -20
# With a key: credit balance and spend
curl -sS https://ai-gateway.vercel.sh/v1/credits -H "Authorization: Bearer $AI_GATEWAY_API_KEY" | jq .
# CLI view of keys and budgets (current scope)
vercel ai-gateway api-keys list && vercel ai-gateway budgets list
Decision flow
- No key: dashboard, CLI or API; on Vercel deployments prefer OIDC (
references/setup-and-auth.md).
- New code: AI SDK or the OpenAI Chat Completions or Anthropic Messages compatible endpoints (
references/api-and-sdks.md).
- Coding agent:
npx vercel@latest ai-gateway setup, or set env vars by hand (references/litellm-and-clients.md).
- Own provider credits or private data access: BYOK (
references/setup-and-auth.md). BYOK spend is outside budgets.
- Cost control: budgets at team, project, key or user level (
references/budgets-and-limits.md).
- Reliability:
providerOptions.gateway.models fallbacks, provider order/only/sort, timeouts (references/routing-and-fallbacks.md).
- Compliance: zero data retention, provider and model allowlists (
references/data-controls.md).
- Done:
references/teardown.md.
Rules
- Ask before spending or storing. Credits, BYOK, budgets, add-ons with per-request surcharges, trace drains.
- Secrets never touch output.
AI_GATEWAY_API_KEY and BYOK provider keys come from env vars or 0600 files. API key values are shown once at creation.
- Budgets are soft caps. The request that crosses the limit still completes. Rejections are HTTP
402 with type: quota_for_entity_exceeded.
- BYOK is not budgeted. Spend through your own provider key is not counted against team, project or key budgets, and failed BYOK calls fall back to system credentials billed to your credits.
- Keys die with their creator. When a member leaves the team, their keys are deactivated. Use OIDC or team-attributed keys for shared automation.
- Pin slugs, then verify. Use
creator/model slugs from GET /v1/models, not names from memory.
- Never hardcode prices. They change per model and provider.
Workflows
1. Get a key
2. Call a model
3. Route and fall back
4. Cap spend
5. Privacy and compliance
6. Connect gateways and agents
7. Tear down and troubleshoot
Reference index
references/setup-and-auth.md: API keys, spend attribution, OIDC, BYOK, free vs paid tier.
references/api-and-sdks.md: base URL, compatible APIs, REST endpoints, model listing.
references/routing-and-fallbacks.md: fallbacks, provider options, timeouts, caching, routing rules.
references/budgets-and-limits.md: budgets, defaults, alerts, rate limits.
references/data-controls.md: ZDR, prompt training, allowlists, logs and trace drains.
references/litellm-and-clients.md: Claude Code, LiteLLM, OpenAI SDK.
references/teardown.md: clean up.
references/troubleshooting.md: symptom to fix.
Companion skills
llm-gateway: gateway design across products. Install: npx skills add ScaleDockHQ/llm-skills --skill llm-gateway.
litellm: self-hosted proxy. Install: npx skills add ScaleDockHQ/llm-skills --skill litellm.
cloudflare-ai-gateway: Cloudflare's hosted alternative. Install: npx skills add ScaleDockHQ/llm-skills --skill cloudflare-ai-gateway.
llm-observability: wider tracing and cost. Install: npx skills add ScaleDockHQ/llm-skills --skill llm-observability.
cloud-llms: provider choice. Install: npx skills add ScaleDockHQ/llm-skills --skill cloud-llms.
1---2name: vercel-ai-gateway3description: Operate Vercel AI Gateway (ai-gateway.vercel.sh), a hosted OpenAI-, Anthropic- and AI SDK-compatible endpoint with model fallbacks, provider routing, BYOK, budgets, logs and zero data retention. Use when the user mentions AI Gateway on Vercel, AI_GATEWAY_API_KEY, VERCEL_OIDC_TOKEN, `provider/model` slugs, providerOptions.gateway, vercel ai-gateway commands, or 402 quota_for_entity_exceeded and 429 errors. For other gateways use llm-gateway, litellm or cloudflare-ai-gateway.4license: MIT5compatibility: Needs a Vercel account or team, an AI Gateway API key in an environment variable or a 0600 file (or an OIDC token on Vercel), curl and jq; the Vercel CLI is optional. Ask the user before buying credits, enabling BYOK, setting budgets, creating or revoking keys, or enabling paid add-ons such as team-wide ZDR or trace drains.6metadata:7 source: https://skillmd.com/skills/scaledockhq/vercel-ai-gateway8 author: ScaleDockHQ9 version: "0.1.0"10---1112# Vercel AI Gateway1314Use one hosted endpoint for hundreds of models: create a key, call it with OpenAI, Anthropic or AI SDK clients, set fallbacks and routing, cap spend with budgets, and clean up.1516**Scope:** the hosted AI Gateway service at `https://ai-gateway.vercel.sh`, its API keys, OIDC, BYOK, budgets, routing rules, fallbacks, logs, privacy options and the `vercel ai-gateway` CLI. Out of scope: self-hosted gateways (`litellm`, `bifrost`, `llm-gateway`), the AI SDK itself, deploying apps on Vercel.1718Work through the steps in order. Load a reference only when a step names it. Model slugs and rates change quickly, so list models live and read prices from the dashboard.1920## Discover first2122Read-only. Nothing here prints a key.2324```bash25env | cut -d= -f1 | grep -E '^(AI_GATEWAY|VERCEL|ANTHROPIC|OPENAI)' || echo "no related env vars"26command -v curl jq vercel2728# Public model catalog, no key needed29curl -sS https://ai-gateway.vercel.sh/v1/models | jq -r '.data[].id' | head -203031# With a key: credit balance and spend32curl -sS https://ai-gateway.vercel.sh/v1/credits -H "Authorization: Bearer $AI_GATEWAY_API_KEY" | jq .3334# CLI view of keys and budgets (current scope)35vercel ai-gateway api-keys list && vercel ai-gateway budgets list36```3738## Decision flow39401. No key: dashboard, CLI or API; on Vercel deployments prefer OIDC (`references/setup-and-auth.md`).412. New code: AI SDK or the OpenAI Chat Completions or Anthropic Messages compatible endpoints (`references/api-and-sdks.md`).423. Coding agent: `npx vercel@latest ai-gateway setup`, or set env vars by hand (`references/litellm-and-clients.md`).434. Own provider credits or private data access: BYOK (`references/setup-and-auth.md`). BYOK spend is outside budgets.445. Cost control: budgets at team, project, key or user level (`references/budgets-and-limits.md`).456. Reliability: `providerOptions.gateway.models` fallbacks, provider `order`/`only`/`sort`, timeouts (`references/routing-and-fallbacks.md`).467. Compliance: zero data retention, provider and model allowlists (`references/data-controls.md`).478. Done: `references/teardown.md`.4849## Rules5051- **Ask before spending or storing.** Credits, BYOK, budgets, add-ons with per-request surcharges, trace drains.52- **Secrets never touch output.** `AI_GATEWAY_API_KEY` and BYOK provider keys come from env vars or `0600` files. API key values are shown once at creation.53- **Budgets are soft caps.** The request that crosses the limit still completes. Rejections are HTTP `402` with `type: quota_for_entity_exceeded`.54- **BYOK is not budgeted.** Spend through your own provider key is not counted against team, project or key budgets, and failed BYOK calls fall back to system credentials billed to your credits.55- **Keys die with their creator.** When a member leaves the team, their keys are deactivated. Use OIDC or team-attributed keys for shared automation.56- **Pin slugs, then verify.** Use `creator/model` slugs from `GET /v1/models`, not names from memory.57- **Never hardcode prices.** They change per model and provider.5859## Workflows6061### 1. Get a key6263- [ ] `vercel ai-gateway api-keys create --name <name> --limit <n> --refresh-period monthly` -> `references/setup-and-auth.md`64- [ ] Save the key to a `0600` file at once; export `AI_GATEWAY_API_KEY`.65- [ ] Verify: `GET /v1/credits` returns JSON, not 401.6667### 2. Call a model6869- [ ] cURL or SDK against `https://ai-gateway.vercel.sh/v1` -> `references/api-and-sdks.md`70- [ ] Verify: the request shows in Logs in the dashboard (kept for 30 days of routing detail).7172### 3. Route and fall back7374- [ ] `models` array, `order`/`only`/`sort`, `providerTimeouts`, team routing rules -> `references/routing-and-fallbacks.md`7576### 4. Cap spend7778- [ ] Team and key budgets, defaults for new keys/projects/users -> `references/budgets-and-limits.md`79- [ ] Verify: an exhausted budget returns 402.8081### 5. Privacy and compliance8283- [ ] ZDR per request or team-wide, allowlists -> `references/data-controls.md`8485### 6. Connect gateways and agents8687- [ ] Claude Code, LiteLLM, OpenAI SDK -> `references/litellm-and-clients.md`8889### 7. Tear down and troubleshoot9091- [ ] Delete test keys, remove budgets and rules, stop add-ons -> `references/teardown.md`92- [ ] `references/troubleshooting.md`9394## Reference index9596- `references/setup-and-auth.md`: API keys, spend attribution, OIDC, BYOK, free vs paid tier.97- `references/api-and-sdks.md`: base URL, compatible APIs, REST endpoints, model listing.98- `references/routing-and-fallbacks.md`: fallbacks, provider options, timeouts, caching, routing rules.99- `references/budgets-and-limits.md`: budgets, defaults, alerts, rate limits.100- `references/data-controls.md`: ZDR, prompt training, allowlists, logs and trace drains.101- `references/litellm-and-clients.md`: Claude Code, LiteLLM, OpenAI SDK.102- `references/teardown.md`: clean up.103- `references/troubleshooting.md`: symptom to fix.104105## Companion skills106107- `llm-gateway`: gateway design across products. Install: `npx skills add ScaleDockHQ/llm-skills --skill llm-gateway`.108- `litellm`: self-hosted proxy. Install: `npx skills add ScaleDockHQ/llm-skills --skill litellm`.109- `cloudflare-ai-gateway`: Cloudflare's hosted alternative. Install: `npx skills add ScaleDockHQ/llm-skills --skill cloudflare-ai-gateway`.110- `llm-observability`: wider tracing and cost. Install: `npx skills add ScaleDockHQ/llm-skills --skill llm-observability`.111- `cloud-llms`: provider choice. Install: `npx skills add ScaleDockHQ/llm-skills --skill cloud-llms`.