openai-streaming
Installation
SKILL.md
OpenAI Streaming Chat Completions
Source: https://github.com/openai/openai-python/blob/main/README.md?plain=1, https://deepwiki.com/openai/openai-python/4.1.2-streaming-chat-completions
Purpose
Deliver Chat Completions responses incrementally via Server-Sent Events (SSE), enabling real-time display of partial results. Supports raw chunk iteration and a higher-level stream manager with semantic events, automatic state accumulation, and incremental JSON parsing for structured outputs.
When to Use
- Real-time chat UIs that display tokens as they arrive
- Long responses where full-completion latency is unacceptable
- Streaming tool calls where incremental fragments matter
- Structured output streaming with progressive JSON parsing
- Any scenario needing low time-to-first-token
Prefer .stream() (the stream manager) for automatic accumulation and semantic events. Use raw stream=True only when you need chunk-by-chunk control.