Streaming
Set stream: true in your Chat Completions request to receive Server-Sent Events (SSE).
How it works
Instead of one JSON response, the server sends a stream of data: lines. Each line contains a partial completion object with a delta field.
Example with cURL
bash
curl https://modelgates.ai/api/v1/chat/completions \ -H "Authorization: Bearer sk-mg-YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "anthropic/claude-sonnet-4", "messages": [{"role": "user", "content": "Count to 10"}], "stream": true }'Parsing the stream
Each chunk looks like this:
code
data: {"id":"gen-xxx","choices":[{"delta":{"content":"1"}}]} data: {"id":"gen-xxx","choices":[{"delta":{"content":"2"}}]} data: [DONE]The final chunk is always data: [DONE].
The OpenAI SDK handles streaming automatically when you set `stream=True`.