The billing layer for AI tools — CLI Billing & Metering SDK
Project description
climeter
Usage-based metering and billing for CLI tools and AI agents — Python SDK.
🌐 climeter.ai · 📖 Docs
Install
pip install climeter
Python 3.8+. Zero runtime dependencies (stdlib only).
Quick Start
from climeter import meter
meter.configure(api_key="clmtr_...", tool_slug="my-tool")
@meter.track(price=0.01)
def search(query: str):
return do_search(query)
Or set environment variables and skip configure():
export CLIMETER_API_KEY=clmtr_...
export CLIMETER_TOOL_SLUG=my-tool
Usage
Decorator
from climeter import meter
@meter.track(price=0.01)
def search(query: str):
return do_search(query)
# Async — same decorator
@meter.track(price=0.01)
async def search_async(query: str):
return await do_search_async(query)
Context manager
with meter.track_usage("search", price=0.01):
result = do_search(query)
# Async
async with meter.track_usage_async("search", price=0.01):
result = await do_search_async(query)
Manual
meter.record("search", price=0.01, metadata={"query_len": len(query)})
Consumer Usage
If you're calling CLIMeter-powered tools as a user (not building them), use the call() function:
from climeter import call, InsufficientBalanceError
try:
result = call("tool-uuid-here")
print(f"Success — balance remaining: ${result['balance_remaining']:.4f}")
except InsufficientBalanceError as e:
print(f"Out of credits. Top up at: {e.checkout_url}")
The call deducts from your CLIMeter wallet (or free tier). If balance is insufficient, InsufficientBalanceError is raised with a checkout_url to top up.
API
| Method | Description |
|---|---|
meter.configure(api_key, tool_slug, api_url) |
Configure the global meter |
@meter.track(price, name, metadata) |
Decorator — records event after each call |
meter.track_usage(name, price, metadata) |
Sync context manager |
meter.track_usage_async(name, price, metadata) |
Async context manager |
meter.record(name, price, metadata) |
Manual event recording |
meter.flush() |
Force-flush pending events |
meter.shutdown() |
Flush and stop background thread |
meter.status() |
Returns {configured, tool_slug, queue_size} |
CLI
climeter init # set up API key
climeter status # show current config
climeter diagnose # test connection
License
MIT © CLIMeter
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
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 climeter-0.1.4.tar.gz.
File metadata
- Download URL: climeter-0.1.4.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0c22925f1798c66e0c154af3ab5d3af7b800748660a9453685d813ea60fcb77
|
|
| MD5 |
ba35345a29ff42c07fadd9f6612dc1fd
|
|
| BLAKE2b-256 |
23e6957170cdf5525f79e92854728ebd87cac185c62a9e7d0839e3d567cdbfe1
|
File details
Details for the file climeter-0.1.4-py3-none-any.whl.
File metadata
- Download URL: climeter-0.1.4-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
575e989b97a174baaede89ed5d2e5a2aa263b28a7f76a8d35b6cf5320c71b62b
|
|
| MD5 |
946c2ba77c94844c52433e8f77488c1d
|
|
| BLAKE2b-256 |
c196acd61c21bfd8008f61533fcc1cf82eccbff03fd0030dd9d1e4f0a786b1f1
|