Enable streaming
Setstream: true in your request:
Stream format
Responses are sent as Server-Sent Events (SSE):All chat models support streaming, including GPU TEE confidential models.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Stream a chat completion as server-sent events with stream: true.
stream: true in your request:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["REDPILL_AI_API_KEY"],
base_url="https://api.redpill.ai/v1"
)
stream = client.chat.completions.create(
model="openai/gpt-5",
messages=[{"role": "user", "content": "Write a long story"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
import OpenAI from 'openai';
const stream = await client.chat.completions.create({
model: 'openai/gpt-5',
messages: [{ role: 'user', content: 'Write a long story' }],
stream: true
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
curl https://api.redpill.ai/v1/chat/completions \
-H "Authorization: Bearer $REDPILL_AI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5",
"messages": [{"role": "user", "content": "Write a story"}],
"stream": true
}'
data: {"id":"chatcmpl-123","choices":[{"delta":{"content":"Hello"}}]}
data: {"id":"chatcmpl-123","choices":[{"delta":{"content":" world"}}]}
data: [DONE]
Was this page helpful?