All tools / AI cost & reliability
llmledger
Meter every customer's AI usage and stop the call before it goes over their allowance.
Buy llmledger for $99One payment of $99, plus sales tax where it applies, and every future update. Delivered as a private GitHub repository you're invited to.
Runs inside Lina. Extracted from the per-customer AI usage metering in Lina.
See it work
python3 llmledger/examples/quickstart.py
call 1: recorded replace-me-small-model, 1200 in / 300 out, $0.000900
call 2: recorded replace-me-large-model, 2050 in / 400 out, $0.033500
call 3: recorded replace-me-small-model-2026-01, 800 in / 240 out, $0.001280
ALERT: acme is at 80% of monthly_calls (4 of 5)
call 4: recorded replace-me-small-model, 1200 in / 300 out, $0.000900
ALERT: acme is at 100% of monthly_calls (5 of 5)
call 5: recorded replace-me-small-model, 1200 in / 300 out, $0.000900
call 6: REFUSED before calling the model: refused: the plan's monthly calls are used up (monthly_calls 5 of 5)
acme this month: 5 calls, 7,990 tokens, $0.0375
Now run: llmledger report --dir quickstart-usage
llmledger report --dir quickstart-usage | head -n 7
llmledger report for 2026-11 (time zone UTC)
customer calls input cached output cost unpriced
-------- ----- ----- ------ ------ ------- --------
acme 5 6,450 3,000 1,540 $0.0375 0
TOTAL 5 6,450 3,000 1,540 $0.0375 0
What it does
llmledger records each model call to an append-only monthly ledger and checks a customer's plan allowance before the next call is made. It reads token counts from OpenAI, Gemini and Anthropic responses, prices them from a table you supply, and needs nothing beyond the standard library.
- An append-only usage ledger
- record() writes one line per model call to a monthly file: customer, model, token counts and cost, never the prompt or the reply. A repeated call id is counted once, across threads and processes.
- Admit before you call
- admit(customer, plan) says whether a call may go ahead, from monthly dollar, token or call limits counted from the ledger rather than from chat history a customer can clear. Months begin in the time zone you set.
- Reads provider responses
- Token counts, cached input and cache writes come straight from OpenAI Chat Completions and Responses, Gemini and Anthropic Messages responses, as dicts or SDK objects. A guard wrapper admits, calls and records in one step.
- Your prices, checked
- Costs come only from a per-million-token price table you write in JSON, TOML or a dict; no prices are bundled. An unpriced model records no cost and a warning, or raises in strict mode, and prices check flags placeholders, zero rates and per-thousand mistakes.
- Alerts at 80% and 100%
- Callbacks you supply fire once per customer per month at each threshold. What has fired is stored, so a restart or a second process stays quiet.
- A daily spend ceiling
- A cap across all customers that admit() enforces. A ceiling that cannot be read, a misspelled setting or environment variable name included, stops the program at start-up and never means no ceiling.
- Units and reports
- A separate ledger for usage that isn't tokens, such as call minutes, keyed by event id so two writers agree on one count. llmledger report gives totals per customer and model as text or JSON.
What you get
llmledger 1.0.3: the Python library and the llmledger command, with an example price table, a config file and a runnable quickstart, with 248 automated tests.
A commercial license. Use it and change it in your own projects and your clients' projects. Don't share or resell the source. Read the license.
Every update. New versions land in the same repository; git pull to get them.
Requirements
Python 3.10 or newer. The Python standard library. The [tz] extra adds tzdata, and [toml] adds TOML config on Python 3.10.
How buying works
- Enter your GitHub username. You'll see the account before you pay, so you can check it's yours.
- Pay $99, plus any sales tax shown at checkout, on Stripe's checkout page.
- Accept the invitation GitHub emails you. Signed in as that account, you'll also find it at
github.com/dominares-tools/llmledger/invitations. Invitations expire after 7 days; you can get a new one any time. - Clone and install:
git clone https://github.com/dominares-tools/llmledger.gitPrivate repo: sign in to GitHub on this computer first. Run
gh auth loginand choose HTTPS, or give git a personal access token when it asks for a password. To use an SSH key instead, clonegit@github.com:dominares-tools/llmledger.git.python3 -m venv .venv && . .venv/bin/activate pip install ./llmledger
Questions
Do I need GitHub?
Yes. Access is a read-only invitation to a private repository, sent to the GitHub account you choose.
Can I get a refund?
Yes, within 14 days, no questions asked. Access ends when the refund goes through. Refund policy.
Who takes the payment?
Payments are handled by Stripe, which works out sales tax. Your receipt and card statement show Link (LINK.COM*), Stripe's checkout service.
Something wrong?
Email support@dominares.org. Every buyer of a tool shares its repository, so support happens by email rather than in GitHub issues.