A Python client for Ollama, sync or async, local or cloud
AI-generated summary of reporting by GitHub Opensource Projects. Read the original for the full story.
Why it matters
Python developers can now use one identical client to call Ollama models locally or via Ollama's cloud API, removing boilerplate and rewriting when scaling up.
Ollama, a tool that lets people run AI models on their own computers, offers an official Python library called ollama-python. It wraps the model's web interface so a few lines of Python can chat with a model, stream replies, or run code asynchronously. Notably, the same code works whether the model runs on your laptop or on Ollama's cloud servers, including large models like gpt-oss:120b. Python developers building with local AI models are the audience.
Ollama's official Python client (ollama-python) lets teams prototype against models on local hardware and switch to Ollama's cloud API, hosting models like gpt-oss:120b, without rewriting integration code; only the model name, host and auth header change. This reduces engineering overhead versus hand-rolled HTTP calls and avoids lock-in to any single inference vendor's SDK. Companies with Python-based AI services gain flexibility; no pricing or benchmark figures are given.
ollama-python is a thin httpx-based wrapper around the Ollama REST API supporting Python 3.8+. It exposes Client and AsyncClient with identical config fields, returns typed ChatResponse objects accessible via dict-style or attribute syntax, and enables streaming with a single stream=True flag (sync iterables or async generators). Cloud access works via local ollama signin plus pull, or directly against https://ollama.com with a Bearer API key header. Extra kwargs pass through to httpx.Client.
Questions this answers
The article above answers these:
- How do I call Ollama models from Python?
- How do I stream Ollama responses in Python?
- How do I use Ollama cloud models from Python with an API key?
Read the original
This summary exists to save you time, not to replace the source.
Key terms
Was this summary useful?
One click, anonymous. It tells us which summaries to re-run.
Related reading
Code-driven AI illustrations are more useful than images from dedicated image models
Code‑driven AI illustrations let designers edit assets directly in code, saving time on iteration and ensuring consistency, which is a game‑changer for teams that need rapid, reusable visual content.
A hierarchical note-taking app for building large personal knowledge bases
Trilium lets users build and navigate massive personal knowledge bases without duplicating content, saving time on organization and retrieval.
Desktop apps in Go with native UI or web frontend
Go developers can now ship cross‑platform desktop and mobile apps in a single small binary without cgo or heavy runtimes, cutting build complexity and deployment size.
OpenBitFun: an agent workspace with four harness modes and phone remote control
OpenBitFun lets agents run on any machine and be controlled from a phone, eliminating the need to choose between local power and remote access, saving developers time switching contexts.
Intel One Mono: a monospaced font designed with low-vision developers
Developers with low vision or eye fatigue can read code more clearly, reducing errors and improving productivity.