cookbook/90_models/ollama/README.md
Note: Fork and clone this repository if needed
Install Ollama and pull a model:
ollama pull llama3.1:8b
python3 -m venv ~/.venvs/aienv
source ~/.venvs/aienv/bin/activate
pip install -U ollama agno
OLLAMA_API_KEY for Ollama Cloudexport OLLAMA_API_KEY=***
The chat/ folder contains examples using the native Ollama Chat API.
# Streaming
python cookbook/90_models/ollama/chat/basic_stream.py
# Non-streaming
python cookbook/90_models/ollama/chat/basic.py
# Async
python cookbook/90_models/ollama/chat/async_basic.py
# Tool use
python cookbook/90_models/ollama/chat/tool_use.py
# Structured output
python cookbook/90_models/ollama/chat/structured_output.py
# Database storage
python cookbook/90_models/ollama/chat/db.py
# Knowledge base
python cookbook/90_models/ollama/chat/knowledge.py
# Memory
python cookbook/90_models/ollama/chat/memory.py
# Pull vision model first
ollama pull llama3.2-vision
python cookbook/90_models/ollama/chat/image_agent.py
python cookbook/90_models/ollama/chat/demo_deepseek_r1.py
python cookbook/90_models/ollama/chat/demo_qwen.py
python cookbook/90_models/ollama/chat/demo_phi4.py
The responses/ folder contains examples using the OpenAI-compatible Responses API (requires Ollama v0.13.3+).
# Basic
python cookbook/90_models/ollama/responses/basic.py
# Streaming
python cookbook/90_models/ollama/responses/basic_stream.py
# Async
python cookbook/90_models/ollama/responses/async_basic.py
# Tool use
python cookbook/90_models/ollama/responses/tool_use.py
# Structured output
python cookbook/90_models/ollama/responses/structured_output.py