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.
Metadata
Release files for loupe-llm 0.1.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 | |
|---|---|---|---|
| loupe_llm-0.1.0.tar.gz | 6.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| loupe_llm-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.1 kB
Release files / loupe_llm-0.1.0.tar.gz
| Download URL | loupe_llm-0.1.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d76458b2b811d910b87b43e6f20717dcf2333aaab0aba1d7ce820f578f4611eb
|
|
BLAKE2b-256 checksum How to use checksums |
b97b636f7bbd4319159e39a2c06e2fe2ac8f5cfcb8b7509e351024b4ca6ef134
|
| 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 Jun 13, 2026.
Transparency logRelease files / loupe_llm-0.1.0-py3-none-any.whl
| Download URL | loupe_llm-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c71cf9c374f5f533580236f277113ce3cff184b0417eefcd61101129665166f9
|
|
BLAKE2b-256 checksum How to use checksums |
33316d34241a3e3644d14b31a2a1a535bfc0dd263c70ce95f2713a3d3e1c17cd
|
| 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 Jun 13, 2026.
Transparency log