
WebSocket support for OpenAI Responses API live on AI Gateway
Quick Answer
AI Gateway now supports WebSocket for the OpenAI Responses API, enabling persistent connections that enhance performance by up to 40% for agentic rollouts with multiple tool calls.
Quick Take
Developers can send incremental inputs with previous response IDs instead of full context, streamlining interactions.
Key Points
- WebSocket mode allows persistent connections for OpenAI Responses API.
- Up to 40% faster execution for agentic rollouts with 20+ tool calls.
- Responses route available at GET /v1/responses over WebSocket.
- Compatible with store=false and Zero Data Retention settings.
- Documentation provides setup instructions and full route list.
📖 Reader Mode
~1 min readAI Gateway now supports WebSocket mode for the OpenAI Responses API. You can keep a persistent connection open and continue each turn by sending only new input items plus previous_response_id, instead of re-sending the full context over a fresh HTTP request every turn.
OpenAI reports up to ~40% faster end-to-end execution on WebSockets for agentic rollouts with 20 or more tool calls.
Copy link to headingRoute Responses API traffic over WebSocket
The Responses route opens at GET /v1/responses and accepts raw response.create frames over a persistent WebSocket connection. The mode is compatible with store=false and Zero Data Retention, and follows OpenAI's WebSocket mode specification upstream.
import WebSocket from 'ws';
const ws = new WebSocket('wss://ai-gateway.vercel.sh/v1/responses', {
headers: { Authorization: `Bearer ${process.env.AI_GATEWAY_API_KEY}` },
});
ws.on('open', () => ws.send(JSON.stringify({
type: 'response.create',
model: 'openai/gpt-5.6-sol',
store: false,
input: 'Pick a gemstone.',
})));
ws.on('message', (data) => {
const event = JSON.parse(data);
if (event.type === 'response.completed') {
ws.send(JSON.stringify({
type: 'response.create',
model: 'openai/gpt-5.6-sol',
store: false,
previous_response_id: event.response.id,
input: 'Which gemstone did you pick?',
}));
}
});
See the AI Gateway documentation for setup and the full route list.
— Originally published at vercel.com
Want this in your inbox every morning?
Daily brief at your local 8am — bilingual EN/中文, free.
More from Vercel AI
See more →
The Agent Stack
The Agent Stack by Vercel AI provides essential building blocks for creating production-grade agents, enabling seamless integration across multiple AI models and secure operations. It features components like AI Gateway for model routing, Workflow SDK for durable execution, and Vercel Connect for scoped access, streamlining agent development and deployment across various platforms.

