Skip to content
Dashboard

The AI Gateway For Developers

Hundreds of models, one enterprise grade pane of glass.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
import { streamText } from 'ai'

const result = streamText({
  model: 'xai/grok-4.3',
  prompt: 'Why is the sky blue?'
})
andmore
0%
0%
Markup on TokensPay provider prices,
never a cent more.

Optimize routing for availability, cost, or latency

If a provider degrades, the Gateway fails over to the same model on another provider. Identical output, no downtime.

Routing, billing, and observability in one place

Providing the developer experience and infrastructure to build, scale, and secure a faster, more personalized web.

  • One API key, hundreds of models. Unified billing and observability across your entire AI stack, with text, image, video, and audio models.
  • Route on behavior, fallback anytime Automatic fallbacks during provider outages so your app stays up even when a model goes down.
  • OpenAI$12.47
    Anthropic$8.22
    xAI$4.31
    Platform fee$0.00
    Total$25.00
    No markup, just fair prices Pay exactly what providers charge with no platform fees.

Works with your existing AI stack

- X_AI_API_KEY- ANTHROPIC_API_KEY- OPEN_AI_API_KEY+ AI_GATEWAY_API_KEY

Move existing OpenAI, Anthropic, and AI SDK integrations to AI Gateway with a base URL swap.

Moving to the gateway is just so ergonomic. We get references to model names, and rely on Vercel to do the correct implementations and handle the edge cases.
Rob CheungCo-founder
  • 20x
    Improvement in AI
    reliability after switching
  • 30s
    To adopt a new model,
    down from an hour of code
  • 25%
    Improvement in average
    latency on model calls

Production-ready,
from request one

Security, spend controls, and compatibility built for teams running real traffic.

Take control

Manage usage across teams with budgets, quotas, and full request visibility.

Set controls
API key management Create, rotate, and revoke keys. Set per-key budgets that enforce spend limits from the dashboard or CLI.
Per-user spending limits. Cap spend for individual users on shared keys. No separate API key required.
Short-lived OIDC tokens. Authenticate with expiring credentials. No static credentials to manage.
See everything
Custom Reporting API. Tag requests by user, customer, feature, or environment. Analyze spend in the dashboard or your own systems.
Dashboard observability. Usage, spend, requests, TTFT, and token counts at team, API key, and project scope.

Works with the tools your team already uses

Route the most popular AI coding agents through AI Gateway with a base URL change. Get unified observability and spend tracking across every tool, no matter who built it.

Get Started

This quickstart walks you through making your first text generation request with AI Gateway.

1Set Up Your Project

Create a new directory and initialize a Node.js project.

Terminal
mkdir ai-text-demo
cd ai-text-demo
pnpm init
2Install Dependencies

Install the AI SDK and development dependencies.

Terminal
npm install ai dotenv @types/node tsx typescript
3Set Up Your API Key

Go to the AI Gateway API Keys page in your Vercel dashboard and click Create Key to generate a new API Key. Create a .env.local file and save your API Key.

.env.local
AI_GATEWAY_API_KEY=your_ai_gateway_api_key
4Create and Run Your Script

Create the index.ts file.

index.ts
import { streamText } from 'ai';
import 'dotenv/config';
async function main() {
const result = streamText({
model: 'openai/gpt-5.5',
prompt: 'Invent a new holiday and describe its traditions.',
});
for await (const textPart of result.textStream) {
process.stdout.write(textPart);
}
console.log();
console.log('Token usage:', await result.usage);
console.log('Finish reason:', await result.finishReason);
}
main().catch(console.error);
5Run your script.

You should see the AI model’s response stream to your terminal.

Terminal
pnpm tsx index.ts

Frequently asked questions