Skip to main content

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


Download files

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

Source Distribution

annapurna_meter-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

annapurna_meter-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

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

Hashes for annapurna_meter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fe5e40239f82e7d5b6aec776b0b7f9401566c9c9317eef495b58d1a8a9b39280
MD5 05131fe6b35e1267c362c54a01101e94
BLAKE2b-256 c2d47d6ca99724a2cce40ae4fab3af453084a1d1ced509332c0b68cb563e6fff

See more details on using hashes here.

Provenance

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

Publisher: release-sdk.yml on costlyinfra-admin/Annapurna

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

File details

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

File metadata

File hashes

Hashes for annapurna_meter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a34fffafdd611b16cd2b30b38cf861f24213c66a12b9d0c9c213d65554eb359
MD5 1ca6d57c7ffed9dbe8d6fcf33d6e6b9e
BLAKE2b-256 cb3af4d1aabe94dbbd26d7e0373d85990f952bd73042cb68e116f2d2583535fa

See more details on using hashes here.

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

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