Chat

Use native Ollama chat for local and cloud models, images, history, knowledge, and tools.

Local examples clear OLLAMA_API_KEY and select the loopback server. The Cloud example uses an API key to select Ollama Cloud.

ExampleDescription
Ollama BasicRun a local Llama 3.1 agent on Ollama in sync, async, and streaming modes.
DBStore local Ollama sessions in Postgres and include earlier turns.
Ollama Demo DeepSeek R1Ask a local DeepSeek-R1 model to write Python for quadratic equations and explain its reasoning.
Ollama Demo GemmaStream a short story about a local image from Gemma 3 12B running on Ollama.
Ollama Demo Phi4Run Microsoft Phi-4 locally through Ollama with a one-shot story prompt.
Ollama Demo QwenBuild an NVDA stock report with Qwen3 on Ollama using YFinanceTools.
Ollama Image AgentDescribe a local image file with Llama 3.2 Vision running on Ollama.
KnowledgeSearch a PgVector knowledge base embedded with OllamaEmbedder from a local Llama agent.
MemoryPersist user memories and session summaries in Postgres with a local qwen2.5 Ollama agent.
Ollama CloudRun gpt-oss:120b on Ollama Cloud with OLLAMA_API_KEY instead of a local Ollama server.
RetryUnderstand the native Ollama retry limitation and configure retries through its compatible endpoint.
Set ClientSupply an explicit Ollama Python client to a local agent.
Ollama Set TemperatureSet sampling temperature on an Ollama model through the options dict.
Ollama Structured OutputRequest JSON and validate a MovieScript with Pydantic through the native local Ollama API.
Tool UseCall WebSearchTools from a local Llama 3.2 agent.