Annapurna metering hook — emit per-call LLM usage events for per-feature cost attribution.
Project description
annapurna-meter
The optional metering hook for Annapurna —
a thin, fail-safe wrapper that reports per-call LLM usage so spend can be
attributed per feature. Stdlib-only, no dependencies. Cost is computed
server-side from Annapurna's pricing tables — the SDK never sees prices, and it
never sends prompt or response content, only token counts and a feature_id.
It is fail-safe: reporting is fire-and-forget on a background thread and can never raise into your request path. With no ingest URL/token configured, every call is a no-op.
Install
pip install annapurna-meter
Use (one line per call)
from annapurna_meter import Meter
meter = Meter(feature_id="feature-threat-triage") # reads ANNAPURNA_INGEST_URL / _TOKEN
resp = anthropic_client.messages.create(model="claude-sonnet-4-6", ...)
meter.record_anthropic(resp) # <- the whole hook
Helpers: record_anthropic, record_openai, record_gemini,
record_openai_compatible, or the generic record(provider=…, model=…, tokens_in=…, tokens_out=…, feature_id=…).
Config
| Env var | What it is |
|---|---|
ANNAPURNA_INGEST_URL |
e.g. https://app.example.com/api/hook/events |
ANNAPURNA_INGEST_TOKEN |
the per-workspace ingest token from the dashboard |
License
Apache-2.0. (The Annapurna server is AGPL-3.0; this client SDK is permissive so you can embed it in a proprietary app.)
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 annapurna_meter-0.1.0.tar.gz.
File metadata
- Download URL: annapurna_meter-0.1.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe5e40239f82e7d5b6aec776b0b7f9401566c9c9317eef495b58d1a8a9b39280
|
|
| MD5 |
05131fe6b35e1267c362c54a01101e94
|
|
| BLAKE2b-256 |
c2d47d6ca99724a2cce40ae4fab3af453084a1d1ced509332c0b68cb563e6fff
|
Provenance
The following attestation bundles were made for annapurna_meter-0.1.0.tar.gz:
Publisher:
release-sdk.yml on costlyinfra-admin/Annapurna
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
annapurna_meter-0.1.0.tar.gz -
Subject digest:
fe5e40239f82e7d5b6aec776b0b7f9401566c9c9317eef495b58d1a8a9b39280 - Sigstore transparency entry: 2190698857
- Sigstore integration time:
-
Permalink:
costlyinfra-admin/Annapurna@eaccc25a7480571573be25808f9c65f05ff9fdd4 -
Branch / Tag:
refs/tags/sdk-v0.1.0 - Owner: https://github.com/costlyinfra-admin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-sdk.yml@eaccc25a7480571573be25808f9c65f05ff9fdd4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file annapurna_meter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: annapurna_meter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 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 |
7a34fffafdd611b16cd2b30b38cf861f24213c66a12b9d0c9c213d65554eb359
|
|
| MD5 |
1ca6d57c7ffed9dbe8d6fcf33d6e6b9e
|
|
| BLAKE2b-256 |
cb3af4d1aabe94dbbd26d7e0373d85990f952bd73042cb68e116f2d2583535fa
|
Provenance
The following attestation bundles were made for annapurna_meter-0.1.0-py3-none-any.whl:
Publisher:
release-sdk.yml on costlyinfra-admin/Annapurna
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
annapurna_meter-0.1.0-py3-none-any.whl -
Subject digest:
7a34fffafdd611b16cd2b30b38cf861f24213c66a12b9d0c9c213d65554eb359 - Sigstore transparency entry: 2190698910
- Sigstore integration time:
-
Permalink:
costlyinfra-admin/Annapurna@eaccc25a7480571573be25808f9c65f05ff9fdd4 -
Branch / Tag:
refs/tags/sdk-v0.1.0 - Owner: https://github.com/costlyinfra-admin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-sdk.yml@eaccc25a7480571573be25808f9c65f05ff9fdd4 -
Trigger Event:
push
-
Statement type: