Quick Start

Get your CLI tool metered and billing in under 5 minutes.

Prerequisites
You need a CLIMeter account and a Stripe account. Both are free to start. Create an account.
1

Install the SDK

Bash
pip install climeter
Python SDK
Install via pip install climeter. Python 3.8+ required. Node.js SDK: npm install @auvh/climeter.
2

Set your API key

Sign in to your CLIMeter dashboard, go to API Keys, and create a new key. It starts with clmtr_.

Bash
export CLIMETER_API_KEY="clmtr_your_key_here"
Keep it secret
Never commit your API key to source control. Use environment variables or a secrets manager.
3

Decorate your function

Import meter and add @meter.track() to your tool function. Pricing is set per-tool in the CLIMeter dashboard — not in code.

my_tool.py
Python
import os
from climeter import meter

meter.configure(
    api_key=os.environ["CLIMETER_API_KEY"],
    tool_slug="my-search-tool",  # CLIMETER_TOOL_SLUG env var also works
)

@meter.track()
def search_code(query: str, repo: str = ".") -> list[dict]:
    """Semantic code search across a repository."""
    results = run_semantic_search(query, repo)
    return results

if __name__ == "__main__":
    # Every call to search_code now records a metering event
    results = search_code("async database connection")
    print(results)
Note
The decorator adds ~5ms overhead per call. Events are fired asynchronously and never block your function response.
4

See it in the dashboard

Call your function once. Within seconds, you will see the event in your CLIMeter dashboard under Events. Connect Stripe to start receiving payouts automatically.

You are live

Your tool is now metered. Share it with users or list it on the CLIMeter Marketplace.

Full working example

complete_example.py
Python
"""
Complete CLIMeter example — a code search tool with metering.
"""
import os
import glob
import re
from climeter import meter

# ── 1. Configure SDK ──────────────────────────────────────────────────────────
# Option A: explicit configure
meter.configure(
    api_key=os.environ["CLIMETER_API_KEY"],  # clmtr_...
    tool_slug="code-search",                 # or set CLIMETER_TOOL_SLUG
)

# Option B: zero-config via env vars only
# export CLIMETER_API_KEY=clmtr_...
# export CLIMETER_TOOL_SLUG=code-search
# (no configure() call needed)

# ── 2. Decorate your tool ─────────────────────────────────────────────────────
@meter.track(command="search-code")
def search_code(query: str, path: str = ".", max_results: int = 10) -> list[dict]:
    """Semantic code search — price configured in CLIMeter dashboard."""
    results = []
    pattern = re.compile(query, re.IGNORECASE)

    for filepath in glob.glob(f"{path}/**/*.py", recursive=True):
        with open(filepath) as f:
            for i, line in enumerate(f, 1):
                if pattern.search(line):
                    results.append({"file": filepath, "line": i, "match": line.strip()})
                    if len(results) >= max_results:
                        return results

    return results

# ── 3. Use normally ───────────────────────────────────────────────────────────
if __name__ == "__main__":
    matches = search_code("async def", path="./src", max_results=5)
    for m in matches:
        print(f"{m['file']}:{m['line']}  {m['match']}")

    # Check SDK state
    print(meter.status())
    # {'configured': True, 'tool_slug': 'code-search', 'queue_size': 1}

    meter.flush()  # ensure all events sent before exit
Quick Start — CLIMeter Docs