> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Ollama Basic

> Run a local Llama 3.1 agent on Ollama in sync, async, and streaming modes.

```python basic.py theme={null}
"""
Ollama Basic
============

Cookbook example for `ollama/chat/basic.py`.
"""

from agno.agent import Agent, RunOutput  # noqa
from agno.models.ollama import Ollama
import asyncio

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

agent = Agent(model=Ollama(id="llama3.1:8b"), markdown=True)

# Get the response in a variable
# run: RunOutput = agent.run("Share a 2 sentence horror story")
# print(run.content)

# Print the response in the terminal

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    # --- Sync ---
    agent.print_response("Share a 2 sentence horror story")

    # --- Sync + Streaming ---
    agent.print_response("Share a 2 sentence horror story", stream=True)

    # --- Async ---
    asyncio.run(agent.aprint_response("Share a breakfast recipe.", markdown=True))

    # --- Async + Streaming ---
    asyncio.run(agent.aprint_response("Share a 2 sentence horror story", stream=True))
```

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno ollama
```

**2. Prepare Ollama**

Install and start Ollama, then pull the model used by this example:

```bash theme={null}
ollama pull llama3.1:8b
```

**3. Run the example**

Save the code above as `basic.py`, then run:

```bash theme={null}
python basic.py
```

Full source: [cookbook/90\_models/ollama/chat/basic.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/90_models/ollama/chat/basic.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.