Skip to main content

meterbase

Python SDK for Meterbase: usage limits, credits and plan entitlements for your app. A sync client and an async one with the same calls, for Python 3.10+.

Install

pip install meterbase

Usage

Check before the work, track after it:

import os

from meterbase import Meterbase

meterbase = Meterbase(api_key=os.environ["METERBASE_API_KEY"])

result = meterbase.check(customer_id="acct_1", meter_id="ai_tokens", quantity=50_000)
if not result.allowed:
    raise RuntimeError(f"Refused: {result.reason}")

completion = generate(prompt)

meterbase.track(
    customer_id="acct_1",
    meter_id="ai_tokens",
    quantity=completion.usage.total_tokens,
)

For asyncio, use AsyncMeterbase and await each call. Use a sandbox key (mb_sk_test_…) for development, CI and staging.

Documentation

Everything else is in the docs:

  • Quickstart
  • Python SDK reference: client options, check, track, reserve, customers, meters, plans, billing, webhooks, errors and retries
  • Guides: gating an LLM call, holding capacity, selling top-ups, FastAPI, Stripe and more
  • Changelog: what each version adds or breaks

Pre-1.0, breaking changes land in the minor version, so pin the minor, such as meterbase~=0.8.0.

Development

uv sync
make test      # against a local test double
make check     # generated code, types, lint, format, build, tests, packaging
make contract  # against a live engine, see .env.example

The async client in src/meterbase/_async is the source; make unasync generates the sync one from it. The contract tests create and delete real data: point them at a sandbox key.

To publish, push a v* tag that matches src/meterbase/_version.py. .github/workflows/publish.yml checks it and publishes it to PyPI.

Metadata

Release files for meterbase 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for meterbase 0.8.1
File Size Uploaded Provenance
meterbase-0.8.1.tar.gz 60.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for meterbase 0.8.1
File Interpreter ABI Platform
meterbase-0.8.1-py3-none-any.whl Python 3 none any Details

Total release size: 141.5 kB

Release files / meterbase-0.8.1.tar.gz

Download URL meterbase-0.8.1.tar.gz
Size 60.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ceb3afcfdec11dc400ae2755a9744c345a54d161c7fa70fb069ae380171c9393
BLAKE2b-256 checksum
How to use checksums
1ff503ce12bf906c0d5675542576d6f8af3cb264d451824174cba613ee51088f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 24, 2026.

Transparency log

Release files / meterbase-0.8.1-py3-none-any.whl

Download URL meterbase-0.8.1-py3-none-any.whl
Size 81.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7e9dbaa603374d91b3c6050935defec808525a59b6d190fbf6f0205e516cff6
BLAKE2b-256 checksum
How to use checksums
93c95b5bb5e050bbae7f3587e4690988c9b65fcb78777ab438e34fd062ba82bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 24, 2026.

Transparency log

Security for meterbase 0.8.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for meterbase-0.8.1.tar.gz

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 Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page