Metadata-Version: 2.5
Name: meterbase
Version: 0.8.1
Summary: Python SDK for the Meterbase engine
Project-URL: Homepage, https://meterbase.tech
Project-URL: Documentation, https://meterbase.tech/docs
Project-URL: Repository, https://github.com/usemeterbase/py-sdk
Author: Meterbase
License-Expression: MIT
License-File: LICENSE
Keywords: billing,entitlements,meterbase,metering,sdk,usage
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx<1,>=0.27
Description-Content-Type: text/markdown

# meterbase

Python SDK for [Meterbase](https://meterbase.tech?utm_source=pypi): 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

```bash
pip install meterbase
```

## Usage

Check before the work, track after it:

```python
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](https://meterbase.tech/docs/quickstart?utm_source=pypi)
- [Python SDK reference](https://meterbase.tech/docs/python-sdk?utm_source=pypi):
  client options, `check`, `track`, `reserve`, customers, meters, plans,
  billing, webhooks, errors and retries
- [Guides](https://meterbase.tech/docs?utm_source=pypi): gating an LLM call,
  holding capacity, selling top-ups, FastAPI, Stripe and more
- [Changelog](https://meterbase.tech/docs/changelog?utm_source=pypi): 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

```bash
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.
