Registry / llm-agents / ollama

ollama

JSON →
library0.6.2pypypi✓ verified 25d ago

Official Python client for Ollama — the local LLM runtime. Wraps the Ollama REST API with native Python types. Requires Ollama to be installed and running locally (or pointed at https://ollama.com for cloud models). Not an inference provider — it's a runtime client.

pip install ollama
INSTALL
IMPORT
SIG · OLLAMA
O
ollama
llm-agentspythonv0.6.2
Install
4.0s avg
Import
774ms
Disk
30MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.798s · 31.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.0s · import 0.750s · 31MB
30MB installed
● package 30MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

chat
from ollama import chat

Basic chat with a locally running model

from ollama import chat response = chat( model='gemma3', messages=[{'role': 'user', 'content': 'Why is the sky blue?'}] ) print(response.message.content)
Debug
Known issues
breakingpip install ollama installs only the Python client — not the Ollama runtime. If the runtime is not installed and running, all calls raise ConnectionError immediately.
fix
Install the Ollama runtime separately from https://ollama.com/download, then run 'ollama serve' (or the desktop app). Verify with: curl http://localhost:11434
affects: all
breakingModels must be explicitly pulled before use. Calling chat() with a model that hasn't been pulled raises a ResponseError with status_code 404.
fix
Run 'ollama pull <model>' before use, or catch ResponseError and call ollama.pull(model) programmatically.
affects: all
breakingTool calling with stream=True is incomplete. When tools are provided, Ollama buffers the full response and returns it as a single block even with stream=True set — true incremental streaming does not occur.
fix
Use stream=False when tools are involved. Track https://github.com/ollama/ollama/issues/9084 for resolution.
affects: all (as of 0.12.x)
gotchapip install ollama-python installs a different, unofficial third-party package with a completely different API (ModelManagementAPI, GenerateAPI classes). It is not the official client.
fix
Use pip install ollama (no hyphen suffix). Official package is at pypi.org/project/ollama.
affects: all
gotchaThe Ollama Python library defaults to http://localhost:11434. To connect to a remote Ollama instance, you must pass host explicitly via Client(host='http://<remote>:11434'). The OLLAMA_HOST env var is respected by the runtime but NOT automatically picked up by the Python client.
fix
Pass host explicitly: Client(host=os.environ.get('OLLAMA_HOST', 'http://localhost:11434'))
affects: all
gotchaThe OpenAI-compatible endpoint is at http://localhost:11434/v1 — but this is a separate REST interface, not the native ollama Python library. Using openai SDK against this endpoint requires api_key='ollama' (any non-empty string) as a placeholder.
fix
from openai import OpenAI; client = OpenAI(base_url='http://localhost:11434/v1', api_key='ollama')
affects: all
gotchaCloud models (e.g. gpt-oss:120b-cloud, deepseek-v3.1:671b-cloud) require ollama signin and ollama pull before use. They are routed through ollama.com and require an API key when accessed via the cloud API endpoint directly.
fix
Run 'ollama signin' first. For direct cloud API access, set host='https://ollama.com' and pass Authorization header with OLLAMA_API_KEY.
affects: >=0.6.0
Upgrade
Version history
0.6.2latest on PyPI · released Apr 29, 2026
Audit
Dependencies
ollama (the runtime)requiredThe Python library is a client for the Ollama runtime. Ollama must be separately installed and running — pip install alone is not sufficient.
Agent activity
57 hits · last 30 days
node
54
Amazon
1
OpenAI (training)
1
Resources
ollama — pip install ollama · libregistry