llm-inference / library
Ollama Python Library
Capability: Ollama Python Library
Use it when
- Your Python application needs chat, generation, or embeddings from models served by a local Ollama instance
- You are hand-writing httpx or requests calls against localhost:11434 and want a typed client with streaming, async, and error handling
What it solves
Not the fit when
- Does not run models itself; an Ollama server must be installed and running
- Not a multi-provider abstraction layer over OpenAI, Anthropic, and others
- Cloud models require an ollama.com sign-in or API key
- running or serving the model itself
- routing across multiple llm providers
- gpu memory capacity limits
Install
pip install ollama (requires Ollama installed and running, with a model pulled via ollama pull <model>)
Invoke
from ollama import chat; chat(model='gemma3', messages=[{'role':'user','content':'...'}]); stream=True for chunks, AsyncClient for async, ollama.embed for embeddingsAlternatives
No reviewed alternatives recorded yet.