AI Gateway
AI Gateway is available on all plans . Your use of each AI provider is subject to their terms listed on each model's page and subject to Vercel's AI Product Terms.
The AI Gateway provides a unified API to access hundreds of models through a single endpoint. It gives you the ability to set budgets, monitor usage, load-balance requests, and manage fallbacks.
AI Gateway works with AI SDK v5 and v6, OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, or your preferred framework.
- One key, hundreds of models. Access models from multiple providers with a single API key
- Unified API. Switch between providers and models with minimal code changes
- High reliability. Automatically retries requests to other providers if one fails
- Embeddings support. Generate vector embeddings for search, retrieval, and other tasks
- Spend monitoring. Monitor your spending across different providers
- No markup on tokens. Tokens cost the same as they would from the provider directly, with zero markup, including with Bring Your Own Key (BYOK)
import { generateText } from 'ai';
const { text } = await generateText({
model: 'anthropic/claude-opus-4.6',
prompt: 'What is the capital of France?',
});
import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv('AI_GATEWAY_API_KEY'),
base_url='https://ai-gateway.vercel.sh/v1'
)
response = client.chat.completions.create(
model='xai/grok-4.1-fast-non-reasoning',
messages=[
{
'role': 'user',
'content': 'Why is the sky blue?'
}
]
)curl -X POST "https://ai-gateway.vercel.sh/v1/chat/completions" \
-H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.4",
"messages": [
{
"role": "user",
"content": "Why is the sky blue?"
}
],
"stream": false
}'Was this helpful?