---
title: "Ollama Integration with Pixeltable: Local Chat as Columns"
description: "Call a local Ollama model from a Pixeltable computed column. chat() on insert, cached per row, with OLLAMA_HOST when the server is remote."
tool: "Ollama"
keywords:
  - Ollama Pixeltable integration
  - Ollama Python pipeline
  - local LLM computed column
  - Ollama chat Pixeltable
  - OLLAMA_HOST Pixeltable
url: "https://www.pixeltable.com/integrations/ollama"
---

# Ollama Integration with Pixeltable: Local Chat as Columns

Call a local Ollama model from a Pixeltable computed column. chat() on insert, cached per row, with OLLAMA_HOST when the server is remote.

## The Problem

Ollama serves local models over HTTP. Wiring that into a table still means a client, a stored prompt, a stored reply, and a rule for when to call again. A script that posts /api/chat for every row will re-run completed prompts unless you add a cache. Moving the server to another host then means changing that script. Pixeltable already has the table. The integration is pixeltable.functions.ollama.chat (and generate) so the model is a column, and OLLAMA_HOST when the daemon is not on localhost.

## The Solution

Install Ollama and pull a model (the docs use qwen3:0.6b). pip install ollama pixeltable. Assign chat() on a TableModel. Insert a prompt and the Message object lands in output; output.message.content is the text. options passes max_tokens, temperature, top_p, and the rest of Ollama valid parameters. Set OLLAMA_HOST to a remote base URL when the daemon is not local. There is no cloud API key on this path. The notebook uses create_table; an application file uses the class assignment and pxt schema update.

## Implementation

### Install Ollama and pull a model

Run a local daemon, pull the model Pixeltable will call, then install the Python client.

```python
# Install the daemon: https://ollama.com/download
# ollama pull qwen3:0.6b
# pip install -U 'pixeltable[serve]' ollama
# Optional remote daemon:
# export OLLAMA_HOST=http://127.0.0.1:11434
# pxt init

import pixeltable as pxt
from pixeltable.functions.ollama import chat

TableModel = pxt.model_base()
```

Verify the daemon with ollama.generate before you depend on the column. Colab and Linux can install via the Ollama install script. A remote server is only OLLAMA_HOST.


### Assign chat() on the class

Store the user message, call the local model, and cache the assistant text.

```python
class Notes(TableModel, name='notes'):
    prompt: pxt.String
    output = chat(
        messages=[{'role': 'user', 'content': prompt}],
        model='qwen3:0.6b',
        options={'max_tokens': 300, 'top_p': 0.9, 'temperature': 0.5},
    )
    response = output.message.content

# pxt schema update app.py ollama_notes -f
```

chat() returns the Ollama chat response. message.content is the assistant string. options is optional. format can be json when you want structured output.


### Insert a prompt and read the reply

Insert runs the local model for that row. Unchanged rows stay cached.

```python
notes = pxt.get_table('ollama_notes.notes')
notes.insert([
    {'prompt': 'What are the most popular services for LLM inference?'},
])
notes.select(notes.prompt, notes.response).collect()
```

The first insert downloads nothing if you already pulled the model. A second prompt is a second row. Editing prompt recomputes that row only.


## ollama.chat in a script versus a computed column

| Job | HTTP client in a loop | chat() column |
| --- | --- | --- |
| You write | Posts to /api/chat and stores the string | An assignment on TableModel |
| Runs when | The script starts | The row or a dependency changes |
| Remote daemon | A base URL in that script | OLLAMA_HOST |

## Benefits

- No hosted LLM key: the daemon on OLLAMA_HOST is the backend
- chat() cached per row, so completed prompts do not re-run
- options pass through Ollama valid parameters
- Same TableModel locally and on a machine that can reach the daemon

## Use Cases

- Offline summarization of stored notes
- Dev laptops that must not send prompts to a hosted API
- Comparing a local model with a hosted column on the same table
- JSON-formatted extraction with format=json

## Performance


| Metric | Value | Description |

| --- | --- | --- |

| Network to a hosted LLM | None | chat() calls the local or remote Ollama daemon you already run |

| Recompute | Changed rows only | Completed prompts stay in the column until the prompt changes |

| Config | OLLAMA_HOST | One environment variable moves the client to another daemon |

## Requirements

- Python 3.11+
- Ollama daemon and a pulled model such as qwen3:0.6b
- pip install -U 'pixeltable[serve]' ollama
- OLLAMA_HOST when the daemon is not localhost

## Resources

- [Working with Ollama](https://docs.pixeltable.com/howto/providers/working-with-ollama) - Install, OLLAMA_HOST, chat(), and a first insert
- [Ollama functions SDK](https://docs.pixeltable.com/sdk/latest/ollama) - chat, generate, and embed
- [Local LLMs with Ollama and Pixeltable](https://www.pixeltable.com/blog/ollama-local-llm-pixeltable) - Product write-up of the local path