module

Smith::LLM::OpenAIStream

Reads an OpenAI-shaped chat completion stream.

Shared by OpenRouter, OpenAI and Ollama — smith talks to Ollama through its OpenAI-compatible /v1/chat/completions endpoint, so all three speak this format.

Class methods

read(io : IO, default_model : String, cache_usage : Bool = false, &on_delta : String -> Nil) : Response

cache_usage switches the usage frame to the reading that carries Anthropic cache counters. Off by default: OpenAI reports a cached_tokens of its own under the same key, billed at its own rate, and treating it as an Anthropic cache read would misprice it.

Source