Skip to Content
GatewaysVercel AI Gateway

Tokenminning with Vercel AI Gateway

Vercel AI Gateway  provides one API key and endpoint for hundreds of models across OpenAI, Anthropic, Google, and more. Zero markup on tokens — you pay provider rates directly.

Hub for the Vercel AI Gateway cluster. Best fit for Next.js apps using the AI SDK .

Quick checklist

  1. Open the Vercel dashboard  → AI Gateway → monitor spend.
  2. Default to mini/haiku models in AI SDK calls — routing.
  3. Configure provider fallbacks for resilience without frontier defaults.
  4. Use BYOK  if you have enterprise provider contracts.
  5. Enable provider-side caching where supported — caching.

Typical impact: 50–90% routing routine inference to mini-tier; spend monitoring catches runaway agent loops early.

How to reduce Vercel AI Gateway spending

1. Measure first

Vercel AI Gateway → Observability shows usage, latency, and spend across providers.

Usage & spend

2. Cap spend

Set provider-level budgets in the Vercel dashboard. Use separate API keys per environment (preview vs production).

Usage & spend

3. Route cheap

Pass providerOptions to prefer cheaper providers. Default model to openai/gpt-4o-mini or anthropic/claude-3-5-haiku for routine work.

Model routing

4. Cache prefixes

Stabilize system prompts in AI SDK system messages. Provider prefix caching passes through the gateway.

Caching

5. Trim upstream bloat

Reduce tool definitions and context in your agent — Context hygiene.

6. Guardrail in prod

Use app attribution  headers to track which features drive spend.

How Vercel AI Gateway bills

No markup on tokens. You pay provider rates. BYOK routes through your own provider keys with the same zero-markup policy.

Guides

GuideWhat you’ll learn
Usage & spendDashboard, observability, billing
Model routingProvider options, fallbacks, model selection
CachingPrefix stability, provider cache passthrough

Anti-patterns

Anti-patternWhy it fails
Frontier model as AI SDK defaultEvery generateText call at max tier
No observability reviewRunaway loops invisible until invoice
AI Gateway + OpenRouter double proxyLatency and fees stack
Last updated on