Streaming
Consume incremental OpenAI or Anthropic server-sent events.
Set stream: true on Chat Completions, Responses, or Messages. The response uses text/event-stream; do not call response.json().
const response = await fetch("https://api.strixgate.dev/v1/chat/completions", options);
if (!response.ok || !response.body) throw new Error(`Request failed: ${response.status}`);
const reader = response.body.getReader();
const decoder = new TextDecoder();
for (;;) {
const { done, value } = await reader.read();
if (done) break;
console.log(decoder.decode(value, { stream: true }));
}Chunks may split across network reads. Production parsers should buffer text until a complete SSE event delimiter is available, then parse each data: line. Chat Completions ends with its completion sentinel. Responses and Anthropic requests are translated to their protocol-specific event names and payload shapes.
Headers arrive before the body and can be inspected immediately. Browser code can read the exposed x-strix-* routing headers on completion requests.