streaming

command
v1.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Example: streaming completions via the channel-based Go API.

Demonstrates two consumer styles:

  1. Iterator: idiomatic for text-only consumers — Stream.Next in a loop.
  2. 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL