Skip to content

Streaming and WebSocket ​

Codex Relay supports regular HTTP responses, SSE streaming, and a Responses WebSocket endpoint for compatible clients.

SSE streaming ​

Set this field in the request body:

json
{
  "stream": true
}

Use -N with curl to disable local buffering:

bash
curl -N https://codexapi.asia/v1/responses \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "input": "Count from one to five.",
    "stream": true
  }'

Streaming displays initial output sooner, but it does not reduce the model's actual computation time.

WebSocket ​

The Responses WebSocket URL is:

text
wss://codexapi.asia/v1/responses

Enable it only when the client explicitly supports Responses WebSocket. Standard OpenAI SDK calls and Chat Completions clients generally use HTTP/SSE.

Proxy considerations ​

  • Cloudflare and reverse proxies must allow long-lived connections and WebSocket Upgrade.
  • Client timeouts should include queueing, inference, and tool execution time.
  • Never cache /v1/* API responses.
  • After a disconnect, retry only requests that are idempotent or safe to replay.

Choose a transport ​

ModeBest for
Non-streaming HTTPScripts, short requests, one complete JSON object
SSEChat, Codex, OpenAI SDK apps, and long text generation
WebSocketClients that explicitly implement Responses WS and persistent sessions