Menu

WebSocket support for OpenAI Responses API live on AI Gateway - Vercel
📰

WebSocket support for OpenAI Responses API live on AI Gateway - Vercel

Vercel News·Kevin Dawkins·5 days ago
#XDbhXXyF
#vercel#websocket#openai#responses#response
Reading 0:00
15s threshold

AI 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 heading Route 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 .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.