Streaming is now the default expectation for production LLM applications. Rather than blocking until a complete response is generated, clients receive tokens as they are produced through Server-Sent Events. This pattern cuts perceived latency and is essential for agentic workflows where reasoning models like DeepSeek R1 or Kimi K2 Thinking may generate long chains of thought that users need to see in real time.
How Streaming Works Under the Hood
When you set stream: true on a chat completion request, the server opens an SSE connection and pushes partial JSON objects. Each chunk contains a choices array with a delta object instead of a full message. A typical chunk carries a token string in delta.content, while the final chunk signals completion through finish_reason. The client simply appends each token to the buffer and renders it.
Because the connection is long-lived, any delay before the first chunk or mid-stream stalls directly degrade the user experience. This makes infrastructure consistency as important as the model itself.
Implementation with the OpenAI SDK
Oxlo.ai exposes streaming through the standard chat completions endpoint and is fully OpenAI SDK compatible. Migrating an existing streaming implementation requires only a base URL change.
import openai
client = openai.OpenAI(
base_url="https://api.oxlo.ai/v1",
api_key="YOUR_OXLO_API_KEY"
)
stream = client.chat.completions.create(
model="llama-3.3-70b",
messages=[{"role": "user", "content": "Explain streaming LLM architecture"}],
stream=True
)
for chunk in stream:
content = chunk.choices[0].delta.content
if content:
print(content, end="")
This same pattern works across the Oxlo.ai catalog, from general-purpose models like Llama 3.3 70B to reasoning specialists like DeepSeek R1 671B MoE and Qwen 3 32B. You can also stream code generation from Qwen 3 Coder 30B or vision responses from Kimi VL A3B without altering client logic.
Why Infrastructure Choices Break or Save Streaming UX
The value of streaming collapses if the first chunk takes multiple seconds to arrive. Cold starts on popular models introduce unpredictable latency that defeats the purpose of real-time delivery. Oxlo.ai serves popular models with no cold starts, so the time-to-first-token remains consistent even under load.
Cost is the other hidden variable. Reasoning and agentic workloads stream thousands of tokens per request. On token-based platforms, longer streams directly inflate the bill. Oxlo.ai uses flat request-based pricing, so a long reasoning trace from DeepSeek R1 or an extended coding session with Qwen 3 Coder 30B costs the same per request as a one-sentence reply. For teams running long-context or agentic workloads, this can reduce costs significantly. See the Oxlo.ai pricing page for plan details.
Advanced Patterns: Tool Use and Reasoning
Streaming becomes more complex when models emit function calls or reasoning tokens. Modern agentic models such as GLM 5, Minimax M2.5, and Kimi K2.6 support tool use while streaming. The client must accumulate chunks until the finish_reason signals tool_calls, then parse the accumulated JSON.
accumulated = ""
for chunk in stream:
delta = chunk.choices[0].delta
if delta.content:
accumulated += delta.content
print(delta.content, end="")
elif delta.tool_calls:
# Accumulate tool call fragments here
pass
if chunk.choices[0].finish_reason == "tool_calls":
execute_tool(accumulated)
For reasoning models, the stream may contain internal chain-of-thought tokens before the final answer. Consuming these in real time lets you display progress indicators or intermediate reasoning steps without waiting for the full response to materialize.
Production Resilience for SSE Connections
Network interruptions mid-stream are common in production environments. Wrap your stream iterator to catch broken connections and retry with truncated context. Always inspect chunk.choices[0].finish_reason to distinguish between a natural stop, a length limit, or a content filter. If you need deterministic outputs across retries, keep the seed and temperature parameters constant.
Getting Started with Oxlo.ai Streaming
Oxlo.ai exposes streaming through the standard /v1/chat/completions endpoint with full OpenAI SDK compatibility in Python, Node.js, or cURL. The free tier includes 60 requests per day across more than 16 models, which is enough to validate streaming behavior before moving to a production plan. Upgrade to Pro or Premium for higher daily volumes and priority queue access.
To migrate an existing application, change your base URL to https://api.oxlo.ai/v1 and confirm that your current retry and parsing logic remains intact. No SDK changes are required.
Top comments (0)