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) andchat.completions.create(OpenAI). Async and streaming are on the roadmap. - Pass
provider="anthropic"|"openai"if auto-detection can't identify a client.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d76458b2b811d910b87b43e6f20717dcf2333aaab0aba1d7ce820f578f4611eb
|
|
| MD5 |
8065bf4dd3f8b52ccc8ba50bf9699e5c
|
|
| BLAKE2b-256 |
b97b636f7bbd4319159e39a2c06e2fe2ac8f5cfcb8b7509e351024b4ca6ef134
|
Provenance
The following attestation bundles were made for loupe_llm-0.1.0.tar.gz:
Publisher:
sdk-release.yml on paarth6011/loupe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
loupe_llm-0.1.0.tar.gz -
Subject digest:
d76458b2b811d910b87b43e6f20717dcf2333aaab0aba1d7ce820f578f4611eb - Sigstore transparency entry: 1809704439
- Sigstore integration time:
-
Permalink:
paarth6011/loupe@29becc6ad06bedc8b66032701045e03651433e31 -
Branch / Tag:
refs/tags/sdk-v0.1.0 - Owner: https://github.com/paarth6011
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-release.yml@29becc6ad06bedc8b66032701045e03651433e31 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c71cf9c374f5f533580236f277113ce3cff184b0417eefcd61101129665166f9
|
|
| MD5 |
94ce4c86938d85f87607d271823b5491
|
|
| BLAKE2b-256 |
33316d34241a3e3644d14b31a2a1a535bfc0dd263c70ce95f2713a3d3e1c17cd
|
Provenance
The following attestation bundles were made for loupe_llm-0.1.0-py3-none-any.whl:
Publisher:
sdk-release.yml on paarth6011/loupe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
loupe_llm-0.1.0-py3-none-any.whl -
Subject digest:
c71cf9c374f5f533580236f277113ce3cff184b0417eefcd61101129665166f9 - Sigstore transparency entry: 1809704445
- Sigstore integration time:
-
Permalink:
paarth6011/loupe@29becc6ad06bedc8b66032701045e03651433e31 -
Branch / Tag:
refs/tags/sdk-v0.1.0 - Owner: https://github.com/paarth6011
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-release.yml@29becc6ad06bedc8b66032701045e03651433e31 -
Trigger Event:
push
-
Statement type: