ollama
The official Python client for Ollama.
What it is and what it does
Ollama is the official Python client library for interacting with Ollama, a system for running large language models locally or via cloud. It wraps Ollama's REST API into a straightforward Python interface, letting you send chat messages, generate text, create embeddings, and manage models without dealing with HTTP calls directly. The library supports both synchronous and asynchronous workflows, streaming responses for real-time output, and custom client configuration via httpx.
The package is designed for developers who want to integrate local or cloud-hosted LLMs into Python applications. It handles the common patterns—chat conversations, single-prompt generation, batch embeddings, and model lifecycle operations—with minimal boilerplate. Dependencies are light (httpx for HTTP, pydantic for response validation), and the API closely mirrors Ollama's REST endpoints, so the learning curve is shallow if you're already familiar with the server.
Use it for:
- Build a chatbot or conversational AI feature in a Python application by sending user messages to a local Ollama instance and streaming responses back.
- Generate text embeddings for semantic search or similarity comparisons without calling an external API.
- Automate model management tasks—pulling, creating, copying, or deleting models—as part of a larger data pipeline.
- Prototype LLM-powered features locally during development before deploying to cloud models via Ollama's cloud API.
- Create an async worker that processes chat or generation requests concurrently using AsyncClient.
- Integrate Ollama cloud models (e.g., gpt-oss, deepseek-v3.1) into Python code by authenticating with an API key.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Python client to interact with Ollama, a local or cloud-based large language model server, enabling chat, text generation, embeddings, and model management through a simple API.
Yes. The package is actively maintained, has no known vulnerabilities, carries a permissive MIT license, and installs with minimal friction. It is the official client for Ollama and is well-suited for any Python project that needs to call local or cloud LLMs. Install it if you are already running Ollama or plan to; if you have no Ollama server, it is not useful on its own.
Install
ollama on PyPI
pip
pip install ollamauv
uv add ollamapoetry
poetry add ollamaInstalling ollama
Before you install
Low install friction with only two runtime dependencies (httpx and pydantic). Actively maintained with a recent release on 2026-04-29 and steady commit activity; the repository shows strong community engagement with 10407 stars.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal restrictions.
Quickstart
pip install ollama
from ollama import chat
response = chat(model='gemma3', messages=[{'role': 'user', 'content': 'Why is the sky blue?'}])
print(response.message.content)
Ollama must be installed and running locally (or accessible at a configured host), and a model must be pulled beforehand (e.g., `ollama pull gemma3`).
Verify before relying
- Whether the package supports Python versions beyond 3.8 despite the requirement stating >=3.8.
- Performance characteristics and latency for streaming responses under typical loads.
- Compatibility guarantees with specific Ollama server versions.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — httpx, pydantic |
| Maintenance | actively maintained — 107 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 19,885,974/month — #1,052 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ollama-0.6.2-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
llama-index-llms-ollamaIntegrates local Ollama language models with…
permissive · top 15,000 on PyPI
xinference-clientA Python client library for connecting to and…
permissive · top 15,000 on PyPI
text-generationProvides a Python client to query text…
permissive · top 15,000 on PyPI
gigachatPython SDK for the GigaChat REST API, a large…
permissive · top 15,000 on PyPI
llama-index-llms-openaiIntegrates OpenAI's language models into…
permissive · top 1,000 on PyPI
llama-index-llms-azure-openaiIntegrates Azure OpenAI language models into…
permissive · top 15,000 on PyPI
g4fAggregates multiple LLM and media-generation…
unclear · top 15,000 on PyPI
llama-index-embeddings-ollamaIntegrates Ollama's local embedding models with…
permissive · top 15,000 on PyPI
llmLLM is a CLI tool and Python library for…
permissive · top 15,000 on PyPI
npmainpmai provides a Python interface to access…
permissive · top 5,000 on PyPI