Skip to main content

Python SDK for Loupe — observability for LLM apps (latency, tokens, cost, errors).

Project description

loupe (Python SDK)

Instrument your LLM calls and ship latency, tokens, cost, and errors to a Loupe backend — in two lines.

# Not yet published to PyPI — install from this repo:
pip install ./sdk
import anthropic
from loupe import track

client = track(anthropic.Anthropic(), workload="support-bot")
# use `client` exactly as before — every call is now observed
resp = client.messages.create(
    model="claude-haiku-4-5",
    max_tokens=200,
    messages=[{"role": "user", "content": "hi"}],
)

Works the same for OpenAI:

from openai import OpenAI
client = track(OpenAI(), workload="rag-pipeline")
client.chat.completions.create(model="gpt-4o", messages=[...])

Configuration (env vars)

Var Default Meaning
LOUPE_URL http://localhost:8000 Loupe backend URL
LOUPE_API_KEY recommended — a per-source ingestion key (sent as X-API-Key)
LOUPE_TOKEN use a pre-obtained bearer JWT instead
LOUPE_USERNAME / LOUPE_PASSWORD admin / admin admin login fallback (dev only)

Create a key in the dashboard (🔑 API keys) or via POST /apikeys, then:

export LOUPE_API_KEY=loupe_sk_…

An API key is preferred over the admin login: it's scoped to ingestion, revocable per source, and needs no login round-trip. Or pass a configured Reporter:

from loupe import Reporter, track
client = track(anthropic.Anthropic(), workload="bot",
               reporter=Reporter(url="https://loupe.internal",
                                 api_key="loupe_sk_…"))

Notes

  • Non-blocking & safe: reporting happens on a background thread and never raises into your code — if Loupe is down, your LLM calls are unaffected.
  • Cost is computed by the backend from the model + token counts (you don't need to send it).
  • v1 covers synchronous messages.create (Anthropic) and chat.completions.create (OpenAI). Async and streaming are on the roadmap.
  • Pass provider="anthropic"|"openai" if auto-detection can't identify a client.

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

loupe_llm-0.1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

loupe_llm-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: loupe_llm-0.1.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for loupe_llm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d76458b2b811d910b87b43e6f20717dcf2333aaab0aba1d7ce820f578f4611eb
MD5 8065bf4dd3f8b52ccc8ba50bf9699e5c
BLAKE2b-256 b97b636f7bbd4319159e39a2c06e2fe2ac8f5cfcb8b7509e351024b4ca6ef134

See more details on using hashes here.

Provenance

The following attestation bundles were made for loupe_llm-0.1.0.tar.gz:

Publisher: sdk-release.yml on paarth6011/loupe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: loupe_llm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for loupe_llm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c71cf9c374f5f533580236f277113ce3cff184b0417eefcd61101129665166f9
MD5 94ce4c86938d85f87607d271823b5491
BLAKE2b-256 33316d34241a3e3644d14b31a2a1a535bfc0dd263c70ce95f2713a3d3e1c17cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for loupe_llm-0.1.0-py3-none-any.whl:

Publisher: sdk-release.yml on paarth6011/loupe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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