> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zespan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Ollama

> Trace local Ollama models via OpenTelemetry auto-instrumentation, no Zespan SDK required.

<Note>
  Available via: **OpenTelemetry auto-instrumentation** (Python). This is not a Zespan SDK wrapper — see [Send traces from any OTel-instrumented app](/sdk/otel-integration#send-traces-from-any-otel-instrumented-app-no-zespan-sdk) for how the underlying endpoint works.
</Note>

[OpenLLMetry](https://github.com/traceloop/openllmetry)'s `opentelemetry-instrumentation-ollama` package patches the official Ollama Python client to emit OTel spans for every call — point the exporter at Zespan and traces show up with no code changes to your Ollama calls themselves.

## Installation

```bash theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
pip install ollama opentelemetry-instrumentation-ollama \
  opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
```

## Setup

```python theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
import ollama
from opentelemetry import trace as trace_api
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.instrumentation.ollama import OllamaInstrumentor

provider = TracerProvider()
provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter(
    endpoint="https://api.zespan.com/v1/traces",
    headers={"x-api-key": "zsp_..."},
)))
trace_api.set_tracer_provider(provider)

OllamaInstrumentor().instrument()

# Every call below is now traced automatically
response = ollama.chat(model="llama3", messages=[{"role": "user", "content": "Hi"}])
```

## Example

Any call through the Ollama client — `chat()`, `generate()`, `embeddings()` — is traced automatically after `.instrument()` runs. No wrapping, no per-call changes.

## What gets captured

By default this instrumentation logs prompts, completions, and token counts as span attributes, mapped through the standard [OpenTelemetry GenAI semantic conventions](/sdk/otel-integration#attributes-zespan-reads) Zespan reads. Set `TRACELOOP_TRACE_CONTENT=false` to disable prompt/completion capture if you only want metadata (latency, tokens, model) — useful if your local models handle sensitive content you don't want persisted.
