AI Gateway

OpenAI Responses API with AI Gateway
SDKs & APIs

https://ai-gateway.vercel.sh/v1
OpenAI Responses API
The Responses API supports the same authentication methods as the main AI Gateway:
Copy page
The OpenAI Responses API is a modern alternative to the Chat Completions API. Point your OpenAI SDK to AI Gateway's base URL and use provider/model identifiers to route requests to OpenAI, Anthropic, Google, and more.
- 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.
Set your SDK's base URL to AI Gateway and use your API key for authentication. See Text generation for a complete first request.
- Text generation - Generate text responses from prompts
- Streaming - Stream tokens as they're generated
- Tool calling - Define tools the model can call
- Structured outputs - Constrain the response to a JSON schema
- Reasoning - Control how much a model thinks before answering
- Images - Send images for analysis
- Compaction - Compress a long conversation into a single item you carry forward
Streaming
Set stream: true to receive tokens as they're generated. See Streaming.
For agent loops that make many requests in a row, you can hold one connection open and send each turn as a frame instead of opening a new HTTP request per turn. See Responses API over WebSocket.
Tool calling
Define tools in tools and the model returns function_call items you execute. See Tool calling.
Structured output
Constrain the response to a JSON schema with text.format. See Structured outputs.
Reasoning
Set reasoning.effort to control how much the model thinks before answering. See Reasoning.
Compaction
POST /v1/responses/compact compresses a long conversation into a single compaction item for OpenAI models. Coding agents such as Codex call it automatically. See Compaction.
Parameters
Required
Parameter
model
input
string or array
string
Model ID in provider/model format (e.g., openai/gpt-6-astra, anthropic/claude-sonnet-5)
Type
Optional
Parameter
A text string or array of input items (messages, function calls, function call outputs)
Description
Type
Stream tokens via server-sent events. Defaults to false
stream
max_output_tokens
integer
boolean
Maximum number of tokens to generate
Description
temperature
Penalizes tokens based on their frequency in the text so far
presence_penalty
Controls randomness (0-2). Lower values are more deterministic
number
number
Nucleus sampling (0-1)
number
frequency_penalty
Tool selection: auto, required, none, or a specific function
number
instructions
string
allowed_tools
parallel_tool_calls
Subset of tool names the model can use for this request
boolean
array
string or object
tool_choice
reasoning
Truncation strategy for long inputs: auto or disabled
truncation
ID of a previous response for multi-turn conversations
object
object
cache_anchor_items
string
previous_response_id
Enables automatic prompt caching. Only auto is supported
text
string
boolean
store
caching
Output format config, including json_schema and json_object for structured output
metadata
object
string
integer
cache_ttl
string
prompt_cache_key
The API returns standard HTTP status codes and error responses.
string
- 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
Key to identify cached prompts (max 64 characters)
Sets the automatic cache lifetime. Accepts 5m (five minutes) or 1h (one hour) and requires caching: 'auto'
Error response format
When an error occurs, the API returns a JSON object with details about what went wrong.
{
Last updated September 8, 2026
"type":"invalid_request_error",
"message":"At least one user message is required in the input"
"error": {
Cross-link map: OpenAI Responses API with AI Gateway (/docs/ai-gateway/sdks-and-apis/responses)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 pagesOpenResponses API with AI Gateway — Use the OpenResponses API specification with AI Gateway for a unified, provider-agnostic interface.OpenAI Responses Text Generation with AI Gateway — Generate text responses with the OpenAI Responses API through AI Gateway.OpenResponses Text Generation with AI Gateway — Generate text responses using the OpenResponses API through AI Gateway.OpenAI Chat Completions API with AI Gateway — Use OpenAI SDKs with the AI Gateway Chat Completions API. Configure the base URL and authentication for chat, streaming,OpenAI Responses Streaming with AI Gateway — Stream tokens as they are generated with the OpenAI Responses API through AI Gateway.This page links to (10)AI Gateway Automatic Prompt Caching — Enable automatic prompt caching and provider-side cache affinity with AI Gateway to reduce costs and latency.OpenAI Chat Completions API with AI Gateway — Use OpenAI SDKs with the AI Gateway Chat Completions API. Configure the base URL and authentication for chat, streaming,OpenAI Responses Compaction with AI Gateway — Compress long conversations into a single compaction item with the OpenAI Responses API through AI Gateway.OpenAI Responses Images and PDFs with AI Gateway — Send images and PDF documents for analysis using the OpenAI Responses API through AI Gateway.OpenAI Responses Reasoning with AI Gateway — Control how much a model thinks before answering with the OpenAI Responses API through AI Gateway.OpenAI Responses Streaming with AI Gateway — Stream tokens as they are generated with the OpenAI Responses API through AI Gateway.OpenAI Responses Structured Outputs with AI Gateway — Constrain a response to a JSON schema with the OpenAI Responses API through AI Gateway.OpenAI Responses Text Generation with AI Gateway — Generate text responses with the OpenAI Responses API through AI Gateway.OpenAI Responses Tool Calling with AI Gateway — Define tools the model can call with the OpenAI Responses API through AI Gateway.OpenAI Responses API WebSocket Mode with AI Gateway — Keep a persistent connection open across turns with the OpenAI Responses API over WebSocket through AI Gateway.Pages that link here (19)By site: vercel-changelog (2) · vercel-web (1) · vercel-docs (16)From vercel-changelogAI Gateway supports OpenAI's Responses APIService tiers now available on AI GatewayFrom vercel-webZero Data Retention 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, rOpenAI Codex with AI Gateway — Connect OpenAI Codex to AI Gateway with one CLI command, or configure it manually.TanStack 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 Audio Input — Analyze recorded audio with AI Gateway, compare audio input with transcription and realtime voice, and choose a supporteAI Gateway File and PDF Input — Send PDFs and documents to AI Gateway models with examples for each supported SDK and API format.AI Gateway Video Input — Analyze video clips with AI Gateway using AI SDK 7, Python, Chat Completions, and Responses / OpenResponses.AI Gateway Automatic Prompt Caching — Enable automatic prompt caching and provider-side cache affinity with AI Gateway to reduce costs and latency.AI Gateway Provider Routing and Fallbacks — Configure provider routing, ordering, and fallback behavior in Vercel 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 Reasoning with AI Gateway — Control how much a model thinks before answering with the OpenAI Responses API through AI Gateway.OpenAI Responses API WebSocket Mode with AI Gateway — Keep a persistent connection open across turns with the OpenAI Responses API over WebSocket through AI Gateway.AI Gateway REST API Reference — Reference for AI Gateway REST endpoints: models, usage, generations, and reporting.
}
Was this helpful?