Skip to main content

respan-instrumentation-ollama

Respan instrumentation plugin for Ollama. It instruments the official Ollama Python client and emits chat, completion, and embedding spans into the Respan tracing pipeline.

Chat spans include canonical request tool definitions and only the tool calls emitted by the current response turn. Streamed calls are marked with llm.is_streaming, and provider HTTP failures retain their explicit status code.

Configuration

1. Install

pip install respan-ai respan-instrumentation-ollama ollama

ollama is the official Ollama Python client. A running Ollama server is required for real model calls.

2. Set Environment Variables

Variable Required Description
RESPAN_API_KEY Yes Your Respan API key.
RESPAN_BASE_URL No Defaults to https://api.respan.ai/api.
OLLAMA_HOST No Ollama server URL. Defaults to the Ollama client default.
OLLAMA_MODEL No Model used by your application.

Quickstart

import os

from dotenv import load_dotenv
from ollama import Client
from respan import Respan, workflow
from respan_instrumentation_ollama import OllamaInstrumentor

load_dotenv()

respan = Respan(
    api_key=os.environ["RESPAN_API_KEY"],
    base_url=os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api"),
    instrumentations=[OllamaInstrumentor()],
)
client = Client(host=os.getenv("OLLAMA_HOST"))


@workflow(name="ollama_quickstart")
def run() -> str:
    response = client.chat(
        model=os.getenv("OLLAMA_MODEL", "llama3.2"),
        messages=[{"role": "user", "content": "Reply with one concise sentence."}],
    )
    return response["message"]["content"]


print(run())
respan.flush()
respan.shutdown()

Further Reading

See the Respan example projects for runnable scripts.

Metadata

Release files for respan-instrumentation-ollama 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for respan-instrumentation-ollama 0.1.1
File Size Uploaded
respan_instrumentation_ollama-0.1.1.tar.gz 12.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for respan-instrumentation-ollama 0.1.1
File Interpreter ABI Platform
respan_instrumentation_ollama-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.2 kB

Release files / respan_instrumentation_ollama-0.1.1.tar.gz

Download URL respan_instrumentation_ollama-0.1.1.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f94d2e96e46bc4114391a2d0294f5572736127860e27549cbd5f6799eff9cb6e
BLAKE2b-256 checksum
How to use checksums
6bd9cbaff00733e3517e7284df5ac1787b6c627c7d6a1312d1c69be08b13fe7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / respan_instrumentation_ollama-0.1.1-py3-none-any.whl

Download URL respan_instrumentation_ollama-0.1.1-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e98d75f468df06021cb81489a742f061f590065042e86c349c68874372b285a
BLAKE2b-256 checksum
How to use checksums
97cf37e7961b09658d666ee940b1e1818bd910bbeb84acd77a1e91913aee7444
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page