Streaming lets you process model output incrementally as it is generated, rather than waiting for the full response. The Ollama provider delivers chunks as server-sent events over a streaming HTTP connection. Both the Chat Completions and Responses APIs support streaming, so you can use it regardless of which endpoint is configured.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/ollama/llms.txt
Use this file to discover all available pages before exploring further.
Basic streaming
Callstream() instead of run(), then iterate over chunks():
$chunk is a plain string containing the next piece of text yielded by the model.
Streaming with the Responses API
Streaming works the same way when using the Responses endpoint. Switch globally and usestream() as usual:
How the two parsers differ
Under the hood, the adapter selects a different stream parser depending on the configured API:- Chat Completions — uses
ChatStreamParser, which parses thedata:lines from Ollama’s/chat/completionsstream and yields each text delta as a string. - Responses API — uses
ResponsesStreamParser, which parses the event stream from Ollama’s/responsesendpoint and yields each text delta as a string.
Generator interface through chunks(), so your application code is identical regardless of which parser is active.
Streaming is one of the declared
ADAPTER_CAPABILITIES in OllamaTextModel, which means it is always available from the adapter’s perspective. Whether the installed model streams correctly depends on the model itself.