Skip to main content

Drop-in observability for LLM calls — cost, tokens, latency, errors via OpenTelemetry GenAI conventions.

Project description

sentrinode-llm

Drop-in observability for your LLM calls. Two lines, and every Anthropic / OpenAI request is traced with model, token usage, latency, finish reason, and computed USD cost — using the OpenTelemetry GenAI semantic conventions.

Install

pip install sentrinode-llm        # add [anthropic] and/or [openai] as needed

Use

import sentrinode_llm
sentrinode_llm.instrument()   # reads SENTRINODE_API_KEY + SENTRINODE_TENANT

import anthropic
client = anthropic.Anthropic()
client.messages.create(            # ← automatically traced
    model="claude-haiku-4-5-20251001",
    max_tokens=256,
    messages=[{"role": "user", "content": "hello"}],
)

That's it — no wrapping your calls, no decorators. The same works for OpenAI:

from openai import OpenAI
OpenAI().chat.completions.create(model="gpt-4o-mini", messages=[...])  # traced

Configure

Env var Meaning Default
SENTRINODE_API_KEY your tenant API key — (required)
SENTRINODE_TENANT your tenant slug — (required)
SENTRINODE_LLM_ENDPOINT ingest base URL https://api.sentrinode.com
SENTRINODE_SERVICE_NAME label for this app llm-app

Or pass them directly: sentrinode_llm.instrument(api_key=..., tenant=...).

What gets recorded

Each call becomes one OpenTelemetry span:

Attribute Example
gen_ai.system anthropic
gen_ai.request.model claude-haiku-4-5-20251001
gen_ai.usage.input_tokens 1432
gen_ai.usage.output_tokens 211
gen_ai.usage.cost_usd 0.002486
gen_ai.response.finish_reasons ["end_turn"]

Cost is computed from pricing.py. Override any model:

sentrinode_llm.set_price("my-model", input_per_1m=2.0, output_per_1m=8.0)

Not yet

  • Streaming responses pass through untraced (usage isn't known until the stream ends — coming next).
  • Async clients and embeddings — next iteration.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sentrinode_llm-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sentrinode_llm-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file sentrinode_llm-0.1.0.tar.gz.

File metadata

  • Download URL: sentrinode_llm-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for sentrinode_llm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d35e7e6e9b1939af600aeadedf2d28961b9faa2610a8e2f0a996d1a5e3d27e41
MD5 d97a138b44d3cc31ea193de93c7e7f9c
BLAKE2b-256 3b52356fe02d0a70e124614c986ba015c4bfbcf135100f8661bf8807a6df4aa1

See more details on using hashes here.

File details

Details for the file sentrinode_llm-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sentrinode_llm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for sentrinode_llm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d3045161c8e6e2733a597257eeed4a33305ce2625764b0cc4d4ea0941bb6041c
MD5 5f6560f5fa0ac6713ce1ca663097278b
BLAKE2b-256 d16b1bda62b3b905ba32da5376da146f91df75df2900ed8225d073f3c2581255

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page