Skip to main content

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.

PyPI License: MIT

🌐 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

climeter-0.1.7.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

climeter-0.1.7-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file climeter-0.1.7.tar.gz.

File metadata

  • Download URL: climeter-0.1.7.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for climeter-0.1.7.tar.gz
Algorithm Hash digest
SHA256 8f344d74b98c069b2e24ca497649773eb852fdc5a4e191ff3efbe2311a9ad050
MD5 143e71d283218aa6959054f13fbac56a
BLAKE2b-256 aa7c70c3d386562e49968774fc67c56af71d527def1eebadd443d49322bab478

See more details on using hashes here.

File details

Details for the file climeter-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: climeter-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for climeter-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ffefe349bee652bf8c4b873523d7046f0b7a1dedac0a38329eae06e99c4b9870
MD5 8cc339071745a4051fe7e817c4f2eaad
BLAKE2b-256 91a23dfb113ef512658f5bd11e2d71c6b0b9fa0893a16db13ae754c10ebf8b87

See more details on using hashes here.

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