Ollama
OLLamaLLMService streams chat completions from Ollama through its OpenAI-compatible API.
Overview
Ollama runs open models on your own machine, behind an OpenAI-compatible API.
OLLamaLLMService: anOpenAILLMServicesubclass with Ollama's base URL and default model.
Upstream page
Pipecat's documentation for the same service.
Source
packages/ollama/src/llm.ts.
Ollama library
The models you can pull.
Installation
bun add @pipedog/ollamaIt depends on @pipedog/openai, which is installed with it.
import { OLLamaLLMService } from "@pipedog/ollama/llm";Prerequisites
- Ollama running locally, with a model pulled (
ollama pull llama2). No API key is needed;apiKeydefaults to"ollama", which a local Ollama ignores.
OLLamaLLMService
Configuration
Prop
Type
The other options (organization, project, defaultHeaders, serviceTier,
retryOnTimeout, retryTimeoutSecs, function calling) are OpenAILLMService's. See
OpenAI.
| Base URL | http://localhost:11434/v1 |
| Default model | llama2 |
| Models to try | llama2, mistral. See the provider's catalog for the rest. |
Settings
Runtime-updatable settings, passed as settings: new OLLamaLLMService.Settings({...})
(OllamaLLMSettings). They are OpenAI's settings, with these
defaults:
| Setting | Type | Default | Description |
|---|---|---|---|
model | string | "llama2" | Model name. |
Every other setting keeps OpenAI's default. Unset sampling settings are left out of the request, so
the provider's own defaults apply. extra carries provider-specific request fields.
Usage
import { LLMUpdateSettingsFrame } from "@pipedog/core/frames/frames";
import { OLLamaLLMService } from "@pipedog/ollama/llm";
const llm = new OLLamaLLMService({
settings: new OLLamaLLMService.Settings({
model: "llama2",
systemInstruction: "You are a helpful assistant in a voice conversation.",
temperature: 0.7,
}),
});An Ollama server on another host, behind a proxy that checks a key:
const remote = new OLLamaLLMService({
baseUrl: "https://ollama.example.com/v1",
apiKey: process.env.OLLAMA_PROXY_KEY ?? "",
settings: new OLLamaLLMService.Settings({ model: "mistral" }),
});Change settings mid-call with an LLMUpdateSettingsFrame. The next completion uses them:
// Queue it on the worker, or push it from a processor upstream of the service.
const update = new LLMUpdateSettingsFrame({
delta: new OLLamaLLMService.Settings({ temperature: 0.2, maxTokens: 300 }),
});Notes
- Runs a completion for each
LLMContextFrame, between anLLMFullResponseStartFrameand anLLMFullResponseEndFrame, and streams the reply asLLMTextFrames, asOpenAILLMServicedoes. Function calls, token usage metrics andrunInferencework the same way. - "developer" messages are sent as "user" messages, since the API doesn't support that role (
supportsDeveloperRoleisfalse). OLLamaLLMServicedoesn't require an API key, unlike the other OpenAI-compatible services, and never falls back toOPENAI_API_KEY.- Ollama seems to ignore "developer" messages, so they are sent as "user" messages.
Runtime notes
| Runtime | Works | What it needs |
|---|---|---|
| Bun | ✅ yes | Nothing. |
| Node.js | ✅ yes | Nothing. |
| Deno | ✅ yes | Nothing. |
| Cloudflare Workers | ✅ yes | Nothing. |
Generated from pipecat.runtimes and pipecat.compat in packages/ollama/package.json: ✅ means the compat smoke test passes on that runtime.
- The client is the official
openaiJS SDK (through@pipedog/openai), which talks throughfetch. It works on Bun, Node, Deno and Cloudflare Workers. - The deprecated
modelconstructor option is not ported. Usesettings. - Tested against a local OpenAI-compatible mock server, not against Ollama itself.
pipedog is an unofficial community TypeScript port of Pipecat. It is not affiliated with or endorsed by Daily or the Pipecat project.
Portions adapted from the Pipecat documentation, Copyright (c) 2024–2025 Daily, BSD-2-Clause (see apps/docs/LICENSE-pipecat-docs).