Streaming (SSE)
Set stream to true in the request body and the response becomes an SSE event stream; on the SDK side it behaves exactly like normal OpenAI streaming.
1. Basic request
curl -N https://aiapigpt.com/v1/chat/completions \
-H "Authorization: Bearer sk-your-sub2api-key" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4o", "stream": true,
"messages": [{"role": "user", "content": "Hello"}]}'
2. Event format
Every event starts with data: and carries a JSON payload shaped like a chunk of the non-streaming response; after everything has been sent you receive data: [DONE] and the connection closes.
data: {"id":"chatcmpl-...","choices":[{"delta":{"content":"Hel"}}]}
data: {"id":"chatcmpl-...","choices":[{"delta":{"content":"lo"}}]}
data: [DONE]
3. Billing
Streaming and non-streaming are billed identically, on the usage the upstream reports.