llm-obs
Lightweight Python SDK for LLM inference logging and observability.
Auto-instruments OpenAI, Anthropic, Google Gemini, AWS Bedrock, Ollama, and any OpenAI-compatible endpoint — zero changes to your LLM call code.
Vendor-neutral: send logs to any HTTP ingestion API that accepts the SDK payload (including self-hosted stacks). The Repana LLM observability platform is one compatible backend, not a requirement.
Related projects
| Project | What it is |
|---|---|
This repo (llm-obs) |
Open-source Python SDK (MIT) |
| llm-observability | Full stack: ingestion API, worker, dashboard (may stay private or partially open) |
Install
# Core SDK
pip install llm-obs
# With provider extras
pip install "llm-obs[openai]"
pip install "llm-obs[anthropic]"
pip install "llm-obs[gemini]"
pip install "llm-obs[bedrock]"
pip install "llm-obs[all]"
Quickstart — one line
from llm_obs import ObservabilityClient
obs = ObservabilityClient(
endpoint="http://localhost:4000", # your ingestion API
api_key="dev-key",
)
obs.auto_instrument() # patches all installed LLM libraries automatically
From this point, every LLM call in your app is logged automatically. No other changes needed.
Stream chat
from llm_obs import stream_chat, set_obs_context
# Set conversation context (picked up automatically by the SDK)
set_obs_context(conversation_id="conv-123")
# Unified streaming across all providers
async for chunk in stream_chat(provider="openai", model="gpt-4o-mini", messages=[
{"role": "user", "content": "Explain Redis in one sentence."}
]):
print(chunk, end="", flush=True)
Provider detection from URL
from llm_obs import detect_provider, available_providers
import os
os.environ["LLM_ENDPOINTS"] = "http://localhost:11434" # Ollama, vLLM, or any URL
# SDK probes the URL and detects what's running
providers = available_providers()
# → {"ollama": ["gemma3:4b", "llama3.2", ...]}
Supported URL detection:
- Ollama — detected via
GET /api/tags - vLLM / LiteLLM / LocalAI — detected via
GET /v1/models - AWS Bedrock — detected from URL pattern (
amazonaws.com) - OpenAI / Anthropic / Google — detected from known API URL patterns
- Private VPC — probed automatically
What gets logged per call
| Field | Description |
|---|---|
provider / model |
Who served the request |
latency_ms |
Total wall-clock time |
ttft_ms |
Time-to-first-token (streaming) |
prompt_tokens / completion_tokens |
Token usage |
cost_usd |
Computed from built-in price table |
status |
success, error, cancelled |
request / response |
PII-redacted payloads |
conversation_id |
Linked via set_obs_context() |
PII redaction
PII is redacted in-process before data leaves via HTTP — email, phone, SSN, credit cards (Luhn), API keys, IPv4, URL secrets.
obs = ObservabilityClient(..., redact_pii=True) # default: True
Manual span
span = obs.start_span(
provider="openai",
model="gpt-4o-mini",
request={"messages": [{"role": "user", "content": "Hello"}]},
conversation_id="conv-123",
)
span.set_ttft(ms=210)
span.set_usage(prompt_tokens=42, completion_tokens=11)
span.end(status="success", streamed=True)
License
MIT
Metadata
Release files for llm-obs 0.1.4
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_obs-0.1.4.tar.gz | 25.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_obs-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 56.9 kB
Release files / llm_obs-0.1.4.tar.gz
| Download URL | llm_obs-0.1.4.tar.gz |
|---|---|
| Size | 25.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a865ba839b9b3242a60d1561a7d4ddd670a4baa4bd6bbb48195d96f03b38c9c9
|
|
BLAKE2b-256 checksum How to use checksums |
8e0ad7aae2807b396f39cccebed399afde0e12033b23a79c7f27c277bf19ece9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency logRelease files / llm_obs-0.1.4-py3-none-any.whl
| Download URL | llm_obs-0.1.4-py3-none-any.whl |
|---|---|
| Size | 31.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91b67b0b5ba6e2f81ad796d0c50db6ad5331e71f19cad5bbcb36d5edd33814f6
|
|
BLAKE2b-256 checksum How to use checksums |
63281abee2074615bf5028b298ada70b29cc44f2f24d4b31345edfe68c68a82d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency log