Skip to main content

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:

  1. Broken prompt caching — where cache_control breakpoints are missing, misplaced, or silently invalidated, and what relocating them would save.
  2. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aliquot-0.0.1.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

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

aliquot-0.0.1-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

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

Hashes for aliquot-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f4b2a78d76c04d8779a7a938b01e77e31f2bc1eb5855b179e73004b75ff38a25
MD5 f3c01a5b0c72f3af639f8517e445bd9c
BLAKE2b-256 17f528220097065b3e4806ef971f4a8be6532d2d4c88a266bc3206dc47f03661

See more details on using hashes here.

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

Hashes for aliquot-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 22aae3606479e9157e297bc07b611a21c48ed396671fe5c60968f80f79a32f00
MD5 adf631a01118e16cac9e71f29d9a4dbd
BLAKE2b-256 7baa525d6586ff61ff7229005135636e1b2925faa61b665c7c54357e95ae4f1b

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