ml frameworksimpleOfficial

Ollama Integration

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

Challenge

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.

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.

Integration Steps

Step 1 of 3

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

# 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.

Use arrow keys to navigate

Key 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

Technical 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

Related Integrations

  • OpenAI

    Modality: Model API

    Computed column: OpenAI: Setup OpenAI Integration

    Docs
  • Anthropic

    Modality: Model API

    Computed column: Anthropic: Install and set the API key

    Docs
  • Gemini

    Modality: Model API

    Computed column: Gemini: Authenticate AI Studio or Vertex

    Docs

Ready to Integrate Ollama?

Get started with Pixeltable and Ollama in minutes.

pip install pixeltable