llm-otel-kit
Drop-in OpenTelemetry GenAI observability for any LLM backend — local or cloud.
What it does
llm-otel-kit gives you full OTel GenAI semantic convention coverage for any LLM provider in ~10 lines of code:
- Traces with
gen_ai.*span attributes (model, tokens, latency, streaming mode) - Metrics — 10 instruments: operation duration, token usage, TTFT, TPOT, throughput, error rate, active requests
- Logs exported via OTLP with structured context (model, duration, token counts)
- Dynatrace-ready — correct temporality (DELTA for counters/histograms, CUMULATIVE for UpDownCounters)
Supported Providers
| Provider | Type | Config name |
|---|---|---|
| Ollama | Local | ollama |
| OpenAI | Cloud | openai |
| Anthropic | Cloud | anthropic |
| vLLM | Local | vllm |
| llama.cpp | Local | llamacpp |
| LM Studio | Local | lmstudio |
| Groq | Cloud | groq |
| Together | Cloud | together |
| Fireworks | Cloud | fireworks |
| Azure OpenAI | Cloud | azure_openai |
| LiteLLM | Proxy | litellm |
Quick Start
from llm_otel_kit import AppConfig, GenAIMetrics, init_observability, create_provider
config = AppConfig.from_env()
otel = init_observability(config.app_name, config.otlp_endpoint, config.otlp_token)
provider = create_provider(config.provider)
m = GenAIMetrics(otel.meter)
# Use provider.complete() / provider.stream() for instrumented LLM calls
Environment Variables
| Variable | Default | Description |
|---|---|---|
LLM_PROVIDER |
ollama |
Provider name (see table above) |
LLM_BASE_URL |
http://localhost:11434 |
Provider API base URL |
LLM_API_KEY |
(empty) | API key for cloud providers |
DEFAULT_MODEL |
(empty) | Fallback model name |
APP_NAME |
llm-backend |
OTel service name |
TRACELOOP_BASE_URL |
(empty) | OTLP endpoint URL |
DT_OTLP_TOKEN |
(empty) | Dynatrace API token |
Install
pip install llm-otel-kit
For Anthropic support:
pip install llm-otel-kit[anthropic]
License
MIT
Metadata
Release files for llm-otel-kit 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| llm_otel_kit-0.2.0.tar.gz | 12.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_otel_kit-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.9 kB
Release files / llm_otel_kit-0.2.0.tar.gz
| Download URL | llm_otel_kit-0.2.0.tar.gz |
|---|---|
| Size | 12.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6871f2cb282aa2b38e27fbe19a9227885ea566a61e77952430143981b0c77b65
|
|
BLAKE2b-256 checksum How to use checksums |
36dadc27a7a1f1527e28e547e7404241884703bdde258014d80e380e6dce3da4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / llm_otel_kit-0.2.0-py3-none-any.whl
| Download URL | llm_otel_kit-0.2.0-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9d1bcf7837ea36bbe7b36c4f9c893d9e2694135bcb8a31cd5054734cee9ea682
|
|
BLAKE2b-256 checksum How to use checksums |
e0dcf5bc871314a6d6b171d8609aae6bc8760229b76e4104826c9123dcb0b047
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|