Skip to main content

Overview

OLLamaLLMService provides access to locally-run Ollama models through an OpenAI-compatible interface. It inherits from BaseOpenAILLMService and allows you to run various open-source models locally while maintaining compatibility with OpenAI’s API format for privacy and cost control.

Ollama LLM API Reference

Pipecat’s API methods for Ollama integration

Example Implementation

Browse examples using Ollama models

Ollama Documentation

Official Ollama documentation and model library

Download Ollama

Download and setup instructions for Ollama

Installation

To use Ollama services, you need to install both Ollama and the Pipecat dependency:
  1. Install Ollama on your system from ollama.com/download
  2. Install Pipecat dependency:
  1. Pull a model (first time only):

Prerequisites

Ollama Local Setup

Before using Ollama LLM services, you need:
  1. Ollama Installation: Download and install Ollama from ollama.com
  2. Model Selection: Pull your desired models (llama2, mistral, codellama, etc.)
  3. Local Service: Ensure Ollama service is running (default port 11434)
  4. Hardware: Sufficient RAM and storage for your chosen models

Configuration

  • No API Keys Required: Ollama runs entirely locally
  • Model Management: Use ollama pull <model> to download models
  • Service URL: Default is http://localhost:11434 (configurable)
Ollama runs as a local service on port 11434. No API key required for complete privacy!

Configuration

str
default:"None"
deprecated
Deprecated since 0.0.105, removed in 2.0.0. Use settings=OLLamaLLMService.Settings(model=...) instead.
OLLamaLLMService.Settings
default:"None"
Runtime-configurable settings. See Settings below.
str
default:"http://localhost:11434/v1"
Base URL for the Ollama API endpoint.
str
default:"\"ollama\""
API key for an Ollama server that requires one, such as one behind an authenticating proxy. A local Ollama ignores it.

Settings

Runtime-configurable settings passed via the settings constructor argument using OLLamaLLMService.Settings(...). These can be updated mid-conversation with LLMUpdateSettingsFrame. See Service Settings for details. This service uses the same settings as OpenAILLMService. See OpenAI LLM Settings for the full parameter reference. The default model is "llama2".

Usage

Basic Setup

With Custom Model and URL

With Custom Settings

Notes

  • No API key is required for a local Ollama. The service passes the placeholder key "ollama" unless you set api_key, which you only need for a server behind an authenticating proxy.
  • The Ollama service must be running locally before starting your pipeline. Start it with ollama serve if it is not already running.
  • Model capabilities (function calling, vision, etc.) depend on the specific model you pull. Check the Ollama model library for details.