AI Gateway
import { generateText } from 'ai';
const { text } = await generateText({
model: 'anthropic/claude-opus-4.8',
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.3',
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.5",
"messages": [
{
"role": "user",
"content": "Why is the sky blue?"
}
],
"stream": false
}'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.
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)
Getting started
Make your first request to AI Gateway with the AI SDK.
Models and providers
Browse hundreds of models from leading providers.
Provider options
Configure routing, fallbacks, and provider preferences.
Web search
Augment model responses with real-time web search.
Observability
Monitor usage, latency, and spend across providers.
Coding Agents
Build coding agents on top of AI Gateway.
Anthropic compatibility
Use the Anthropic Messages API through AI Gateway.
OpenAI compatibility
Use the OpenAI Chat Completions API through AI Gateway.
Disallow prompt training
Control whether your prompts can be used for training.
Usage and billing
Understand pricing, usage metrics, and billing.
Authentication
Authenticate requests with API keys or OIDC tokens.
Bring your own key
Use your own provider keys with AI Gateway.
Framework integrations
Use AI Gateway with your preferred framework.
App attribution
Track which apps are making requests through AI Gateway.
Was this helpful?