Audit your Anthropic API logs and find the money wasted on broken prompt caching and tool-definition bloat.
Project description
Aliquot
Audit your Anthropic API logs and find the money you're wasting on broken prompt caching and tool-definition bloat.
Status: pre-alpha (Phase 0 — setup). Not yet functional.
pip install aliquot # coming soon
aliquot audit ./logs.jsonl
SCANNED: 12,847 requests over 7 days
TOTAL SPEND: $1,247
ESTIMATED WASTE: up to $782 (likely $620-780) [63%]
ISSUE 1: Cache miss on system prompt [saves up to $412/mo, likely $340-410]
...with the math to back it up.
Aliquot (chemistry): a portion taken from a whole for analysis. Your audit logs are the aliquot of your full AI usage.
What it does
Reads raw Anthropic JSON logs and produces a markdown report showing, with the math:
- Broken prompt caching — where
cache_controlbreakpoints are missing, misplaced, or silently invalidated, and what relocating them would save. - MCP / tool-definition bloat — tools loaded on every request but rarely or never called, and the savings from trimming them.
Read-only. Never modifies your code or sends data anywhere.
Getting your logs
Aliquot reads raw Anthropic request+response records (one JSON object per line).
Anthropic doesn't hand you these — the usage cache fields only come back in each
API response at call time, so you capture them yourself. The easiest way is to log
your calls as you make them:
from examples.capture_logs import logged_create # 3-line wrapper around messages.create
logged_create(client, model="claude-opus-4-8", max_tokens=512,
system=SYSTEM, messages=messages) # appends to anthropic_logs.jsonl
Then aliquot audit ./anthropic_logs.jsonl. See examples/capture_logs.py
for the full snippet (model, system, messages, tools, and the response usage).
If you already log your Claude calls, point Aliquot at those — it needs the request
(system/messages/tools) and the response usage. Logs from wrappers like LangChain
aren't supported in v1; you'll get a clear error rather than a wrong answer.
How the cache detector works
(Diagram + write-up coming — Phase 11. Short version: tokenize each request, build a prefix trie across all requests, cluster by structural template shape to find variable slots, classify the cache failure mode, and project savings validated by a replay harness against simulated cache behavior.)
Scope (v1)
- One log format: raw Anthropic JSON.
- One provider: Anthropic. (OpenAI/Gemini are v2 — caching semantics differ.)
- CLI + markdown report. No dashboard, no server, no cloud.
Development
uv pip install -e ".[dev]"
ruff check . && mypy && pytest
All pricing/TTL/cache constants live in src/aliquot/pricing.py with a
LAST_VERIFIED date; CI fails if it's more than 60 days old.
License
MIT
Project details
Release history Release notifications | RSS feed
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 aliquot-0.0.1.tar.gz.
File metadata
- Download URL: aliquot-0.0.1.tar.gz
- Upload date:
- Size: 23.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4b2a78d76c04d8779a7a938b01e77e31f2bc1eb5855b179e73004b75ff38a25
|
|
| MD5 |
f3c01a5b0c72f3af639f8517e445bd9c
|
|
| BLAKE2b-256 |
17f528220097065b3e4806ef971f4a8be6532d2d4c88a266bc3206dc47f03661
|
File details
Details for the file aliquot-0.0.1-py3-none-any.whl.
File metadata
- Download URL: aliquot-0.0.1-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22aae3606479e9157e297bc07b611a21c48ed396671fe5c60968f80f79a32f00
|
|
| MD5 |
adf631a01118e16cac9e71f29d9a4dbd
|
|
| BLAKE2b-256 |
7baa525d6586ff61ff7229005135636e1b2925faa61b665c7c54357e95ae4f1b
|