Skip to main content
Ollama runs open-weight models locally. In Python, the OllamaInstrumentor traces native Ollama chat calls, including messages, responses, tool calls, and token counts, as OpenInference LLM spans in Arize AX. Ollama also exposes an OpenAI-compatible API, so Node.js and Go applications can call it with the OpenAI SDK and trace it with the OpenInference OpenAI instrumentation for JavaScript / TypeScript or Go.

Llama 3.2 + Ollama Tracing Tutorial (Google Colab)

Prerequisites

  • Python 3.10+, Node.js 22+, or Go 1.25+
  • An Arize AX account (sign up)
  • Ollama installed and running locally
  • The llama3.2:1b model pulled: 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

Configure credentials

Ollama runs locally, so this example needs no provider API key. The OpenAI SDKs require an API key value, so the TypeScript and Go examples pass the placeholder ollama, which a local Ollama server ignores.

Setup tracing

Import and instrument before importing or calling ollama. In particular, from ollama import chat captured before instrumentation is not traced. In TypeScript, instrumentation.manuallyInstrument(OpenAI) must run before your code creates an OpenAI client.

Run Ollama

Expected output

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 with an LLM span: Chat for the Python SDK, OpenAI Chat Completions for the Node.js SDK, or openai.chat.completions.create for the Go SDK.
  3. If no traces appear, see Troubleshooting.

Check from the skill, CLI, or SDK

Confirm spans are actually reaching your Arize AX project. Use whichever fits your workflow — the skill and CLI work for any framework; the SDK check is shown for each language.
Install the Arize Skills plugin and let your coding agent check for you:
Then prompt your agent:
Use the arize-trace skill to export and analyze recent traces from my project. Confirm spans are arriving, and summarize any errors or latency issues.

Troubleshooting

  • No traces in Arize AX. Confirm ARIZE_SPACE_ID and ARIZE_API_KEY are set in the same shell that runs the example. In Python, run OllamaInstrumentor().instrument(...) before importing or calling ollama. In TypeScript, make sure ./instrumentation is the first import in your entry point.
  • Connection refused. Start the daemon with ollama serve and confirm it responds at http://localhost:11434.
  • Model not found. Pull it with ollama pull llama3.2:1b.
  • No span for generate or embeddings (Python). This instrumentor traces chat only; generate, embed, and embeddings calls are not supported.
  • No span for embeddings (Go). The Go middleware instruments /v1/chat/completions, /v1/responses, and /v1/decisions. Other endpoints pass through unchanged, and no span is emitted for them.
  • Go process exits before spans flush. The defer tp.Shutdown(...) block in main.go flushes the batched span processor. Without it, short-lived programs lose their last spans.

Resources

Ollama OpenAI compatibility

OpenInference Ollama Instrumentor

OpenInference OpenAI Instrumentor (JS/TS)

OpenInference OpenAI Instrumentor (Go)

Ollama Python client