Documentation
¶
Overview ¶
Example: streaming completions via the channel-based Go API.
Demonstrates two consumer styles:
- Iterator: idiomatic for text-only consumers — Stream.Next in a loop.
- Channel: idiomatic for select-based code — provider.NewChannelAdapter publishes typed StreamChunk values that you can multiplex with ctx.Done, timers, or other goroutines.
Plus an Accumulate demo that drains a stream into a final CompletionResponse with merged content, reasoning, and tool calls — the same shape Provider.Complete would have returned.
Run:
OPENAI_API_KEY=sk-... go run ./_examples/streaming
Click to show internal directories.
Click to hide internal directories.