AI Gateway

OpenAI Chat Completions API with AI Gateway
SDKs & APIs

AI Gateway provides OpenAI Chat Completions API endpoints, letting you use multiple AI providers through a familiar interface. You can use existing OpenAI client libraries, switch to AI Gateway with a URL change, and keep your current tools and workflows without code rewrites.
OpenAI Chat Completions API
How is your data secured?
https://ai-gateway.vercel.sh/v1
The Chat Completions API is available at the following base URL:
The Chat Completions API implements the same specification as the OpenAI Chat Completions API.
The Chat Completions API supports the same authentication methods as the main AI Gateway:
- API key: Use your AI Gateway API key with the
Authorization: Bearer
header - OIDC token: Use your Vercel OIDC token with the
Authorization: Bearer
header
You only need to use one of these forms of authentication. If an API key is specified it will take precedence over any OIDC token, even if the API key is invalid.
Supported endpoints
The AI Gateway supports the following Chat Completions API endpoints:
- GET /models - List available models
- GET /models/{model} - Retrieve a specific model
- POST /chat/completions - Create chat completions, with support for streaming, file attachments, tool calling, and structured outputs
- POST /embeddings - Generate vector embeddings
For advanced features, see:
- Reasoning - Control how much a model thinks before answering
- File attachments - Send images and PDF documents to a model
- Advanced configuration - Provider options, model fallbacks, BYOK, and prompt caching
- Image generation - Generate images using multimodal models
- Direct REST API usage - Use the API without client libraries
Integration with existing tools
You can use the AI Gateway's Chat Completions API with existing tools and libraries like the OpenAI client libraries and AI SDK. Point your existing client to the AI Gateway's base URL and use your AI Gateway API key or OIDC token for authentication.
Python
constopenai=newOpenAI({
import OpenAI from'openai';
baseURL:'https://ai-gateway.vercel.sh/v1',
});
});
model:'anthropic/claude-opus-5',
constresponse=awaitopenai.chat.completions.create({
apiKey:process.env.AI_GATEWAY_API_KEY,
messages: [{ role:'user', content:'Hello, world!' }],
For compatibility with AI SDK and AI Gateway, install the @ai-sdk/openai-compatible package.
name:'openai',
constgateway=createOpenAICompatible({
apiKey:process.env.AI_GATEWAY_API_KEY,
import { generateText } from'ai';
import { createOpenAICompatible } from'@ai-sdk/openai-compatible';
});
});
prompt:'Hello, world!',
model:gateway('anthropic/claude-opus-5'),
constresponse=awaitgenerateText({
baseURL:'https://ai-gateway.vercel.sh/v1',
List models
Retrieve a list of all available models that can be used with the AI Gateway.
Endpoint
GET /models
Example request
Python
import OpenAI from'openai';
cURL
baseURL:'https://ai-gateway.vercel.sh/v1',
});
console.log(models);
constopenai=newOpenAI({
constmodels=awaitopenai.models.list();
apiKey:process.env.AI_GATEWAY_API_KEY,
Although this Website may be linked to other websites, we are not, directly or indirectly, implying any approval.
Response format
The response follows the OpenAI API format:
Our Services
{
Digital Marketing
{
"data": [
"object":"list",
"id":"anthropic/claude-opus-5",
"object":"model",
Brand & Design
{
"created":1677610602,
"owned_by":"anthropic"
"object":"model",
"id":"openai/gpt-6-astra",
}
]
"created":1677610602,
"owned_by":"openai"
},
}
Endpoint
Parameters
model (required): The model ID to retrieve (e.g., anthropic/claude-opus-5)
You can reach our customer support team by emailing info@yourcompany.example.com, calling +1 555-555-5556, or using the live chat on our website. Our dedicated team is available 24/7 to assist with any inquiries or issues.
We’re committed to providing prompt and effective solutions to ensure your satisfaction.
We offer a 30-day return policy for all products. Items must be in their original condition, unused, and include the receipt or proof of purchase. Refunds are processed within 5-7 business days of receiving the returned item.
Python
import OpenAI from'openai';
cURL
baseURL:'https://ai-gateway.vercel.sh/v1',
});
console.log(model);
constopenai=newOpenAI({
constmodel=awaitopenai.models.retrieve('anthropic/claude-opus-5');
apiKey:process.env.AI_GATEWAY_API_KEY,
Although this Website may be linked to other websites, we are not, directly or indirectly, implying any approval.
{
Response format
"object":"model",
"id":"anthropic/claude-opus-5",
}
"owned_by":"anthropic"
"created":1677610602,
The API returns standard HTTP status codes and error responses:
- 400 Bad Request: Invalid request parameters
- 401 Unauthorized: Invalid or missing authentication
- 403 Forbidden: Insufficient permissions
- 404 Not Found: Model or endpoint not found
- 429 Too Many Requests: Rate limit exceeded
- 500 Internal Server Error: Server error
{
"error": {
"message":"Invalid request: missing required parameter 'model'",
"type":"invalid_request_error",
"param":"model",
"code":"missing_parameter"
}
}
Last updated September 8, 2026
Cross-link map: OpenAI Chat Completions API with AI Gateway (/docs/ai-gateway/sdks-and-apis/openai-chat-completions)From the Vercel docs graph (built 2026-09-21T05:26:59.511Z), spanning vercel.com docs + KB, nextjs.org, ai-sdk.dev, and other Vercel documentation sites. Full graph as JSON: https://vercel.com/docs/graph.jsonSemantically closest pagesOpenAI Chat Completions Requests with AI Gateway — Create chat completions using the Chat Completions API with support for streaming, image attachments, and PDF documentsOpenAI Responses API with AI Gateway — Use the OpenAI Responses API with AI Gateway to generate text, call tools, stream tokens, and more across any supportedPython with AI Gateway: OpenAI and Anthropic SDKs — Use AI Gateway with Python through OpenAI or Anthropic SDKs with full streaming, tool calling, and async support.OpenAI Chat Completions Images and PDFs with AI Gateway — Send images and PDF documents to a model using the OpenAI Chat Completions API through AI Gateway.OpenResponses API with AI Gateway — Use the OpenResponses API specification with AI Gateway for a unified, provider-agnostic interface.This page links to (12)OpenAI Compatible ProvidersAI Gateway Authentication and BYOK — Authenticate AI Gateway requests with API keys or OIDC tokens, and configure bring your own key \(BYOK\) credentials forOpenAI Chat Completions Configuration with AI Gateway — Configure provider options, model fallbacks, BYOK credentials, and prompt caching through AI Gateway.OpenAI Chat Completions Requests with AI Gateway — Create chat completions using the Chat Completions API with support for streaming, image attachments, and PDF documentsOpenAI-Compatible Embeddings API with AI Gateway — Generate vector embeddings with the OpenAI-compatible /embeddings endpoint through Vercel AI Gateway, including the dimeAI Gateway Chat Completions Image Generation Reference — Generate images using AI models that support multimodal output through the Chat Completions API through AI Gateway.OpenAI Chat Completions Images and PDFs with AI Gateway — Send images and PDF documents to a model using the OpenAI Chat Completions API through AI Gateway.OpenAI Chat Completions Reasoning with AI Gateway — Control how much a model thinks before answering with the OpenAI Chat Completions API through AI Gateway.Call AI Gateway Chat Completions with REST — Use AI Gateway API directly without client libraries using curl and fetch.OpenAI Chat Completions Streaming with AI Gateway — Stream OpenAI Chat Completions responses token by token as they are generated through AI Gateway.OpenAI Chat Completions Structured Outputs with AI Gateway — Generate structured JSON responses that conform to a specific schema using the Chat Completions API through AI Gateway.OpenAI Chat Completions Tool Calling with AI Gateway — Use function calling with the Chat Completions API to enable models to call tools and functions through AI Gateway.Pages that link here (10)By site: vercel-changelog (1) · vercel-docs (9)From vercel-changelogService tiers now available on AI GatewayFrom vercel-docsVercel AI Gateway: Models, Routing, and Observability — Call AI models from any infrastructure through a managed gateway. Centralize credentials, request logs, spend budgets, rAI Gateway Framework Integrations — Connect LangChain, LiteLLM, LlamaIndex, Mastra, Pydantic AI, TanStack AI, and other frameworks to Vercel AI Gateway withTanStack AI with AI Gateway — Connect TanStack AI to Vercel AI Gateway with the official adapter to authenticate requests and stream responses from AIAI Gateway Text Generation Quickstart — Generate and stream text responses using AI Gateway.AI Gateway Reasoning — Discover model reasoning capabilities and configure effort across AI SDK, Chat Completions, Messages, and Responses withAI Gateway SDKs and APIs — Connect to AI Gateway with the AI SDK, Python, REST, or compatible OpenAI, Anthropic Messages, OpenResponses, and CohereAI SDK with AI Gateway — Build AI-powered TypeScript applications using the AI SDK with AI Gateway for unified access to 200+ models.Python with AI Gateway: OpenAI and Anthropic SDKs — Use AI Gateway with Python through OpenAI or Anthropic SDKs with full streaming, tool calling, and async support.OpenAI Responses API with AI Gateway — Use the OpenAI Responses API with AI Gateway to generate text, call tools, stream tokens, and more across any supported