Skip to main content

Documentation Index

Fetch the complete documentation index at: https://arize-ax.mintlify.dev/docs/llms.txt

Use this file to discover all available pages before exploring further.

Ollama runs open-source models locally and exposes an OpenAI-compatible Chat Completions API at http://localhost:11434/v1. Because the client side speaks the OpenAI protocol, Arize AX captures every Ollama call via the openinference-instrumentation-openai package — the same instrumentor that covers OpenAI’s hosted API.
https://storage.googleapis.com/arize-phoenix-assets/assets/images/phoenix-docs-images/gc.ico

Llama 3.2 + Ollama Tracing Tutorial (Google Colab)

Prerequisites

  • Python 3.9+
  • An Arize AX account (sign up)
  • Ollama installed and running locally (ollama serve)
  • A small instruction-tuned model pulled (this guide uses llama3.2:1b):
    ollama pull llama3.2:1b
    

Launch Arize AX

  1. Sign in to your Arize AX account.
  2. From Space Settings, copy your Space ID and API Key. You will set them as ARIZE_SPACE_ID and ARIZE_API_KEY below.

Install

pip install arize-otel openinference-instrumentation-openai openai

Configure credentials

export ARIZE_SPACE_ID="<your-space-id>"
export ARIZE_API_KEY="<your-api-key>"
export ARIZE_PROJECT_NAME="ollama-tracing-example"
Ollama does not require an API key — the OpenAI client passes a literal placeholder. No external provider key is needed.

Setup tracing

# instrumentation.py
import os

from arize.otel import register
from openinference.instrumentation.openai import OpenAIInstrumentor

tracer_provider = register(
    space_id=os.environ["ARIZE_SPACE_ID"],
    api_key=os.environ["ARIZE_API_KEY"],
    project_name=os.environ["ARIZE_PROJECT_NAME"],
)

OpenAIInstrumentor().instrument(tracer_provider=tracer_provider)
print("Arize AX tracing initialized for Ollama.")

Run Ollama

# example.py

# Importing instrumentation first ensures tracing is set up
# before `openai` is imported.
from instrumentation import tracer_provider

from openai import OpenAI

# Point the OpenAI client at the local Ollama server. The api_key is required
# by the client but is not validated by Ollama.
client = OpenAI(
    base_url="http://localhost:11434/v1",
    api_key="ollama",
)

response = client.chat.completions.create(
    model="llama3.2:1b",
    messages=[
        {
            "role": "user",
            "content": "Why is the ocean salty? Answer in two sentences.",
        },
    ],
)

print(response.choices[0].message.content)

Expected output

Arize AX tracing initialized for Ollama.
The ocean is salty because rivers continuously dissolve mineral salts from rocks and soil and carry them to the sea, where they accumulate over millions of years. Water leaves the ocean through evaporation but the salts remain, steadily concentrating until reaching today's roughly 3.5% salinity.

Verify in Arize AX

  1. Open your Arize AX space and select project ollama-tracing-example.
  2. You should see a new trace within ~30 seconds containing a ChatCompletion LLM span with the prompt, response, and token usage attached. The model name on the span will be the Ollama model you ran (e.g. llama3.2:1b).
  3. If no traces appear, see Troubleshooting.

Troubleshooting

  • No traces in Arize AX. Confirm ARIZE_SPACE_ID and ARIZE_API_KEY are set in the same shell that runs example.py. Enable OpenTelemetry debug logs with export OTEL_LOG_LEVEL=debug and re-run.
  • Connection refused or ConnectError to localhost:11434. The Ollama daemon is not running. Start it with ollama serve (in another terminal, or as a background service).
  • model "llama3.2:1b" not found, try pulling it first. Pull the model: ollama pull llama3.2:1b. Run ollama list to see what’s pulled locally.
  • Different model. Swap llama3.2:1b for any model in the Ollama library you’ve pulled — llama3.3, mistral, qwen2.5, etc. The OpenAIInstrumentor doesn’t care which model serves the response.
  • Spans show but with the wrong model name. Ollama reports the model alias you passed to the API; if you renamed the model locally (ollama cp), use that alias.

Resources

Ollama OpenAI Compatibility Documentation

OpenInference OpenAI Instrumentor (used for Ollama)

Ollama GitHub