Skip to main content

Cut AWS Bedrock LLM spend from Claude Code — compression + prompt caching, on your machine.

Project description

caprock

Cut your Claude Code token bill — context compression + prompt caching, on your machine, with your own credentials. Works on AWS Bedrock (where it also fixes prompt caching that's silently broken) and on the direct Anthropic API. Nothing leaves your machine.

pipx install caprock         # macOS/Homebrew — smoothest (or: uvx caprock, or plain pip, Python 3.10+)
caprock wrap claude          # your Claude Code now runs through it
caprock stats                # see what you saved

Upgrades: pipx upgrade caprock / pip install -U caprock. Full install matrix + troubleshooting: https://caprock.dev/docs.

Which backend?

Say it explicitly and it always wins:

caprock wrap claude --bedrock                     # force AWS Bedrock (your AWS creds)
caprock wrap claude --bedrock --profile work      # …signing with a specific AWS profile
caprock wrap claude --anthropic                   # force the direct Anthropic API

--profile <name> picks which AWS profile signs Bedrock (it implies --bedrock); without it caprock uses your AWS_PROFILE / default profile — the startup line tells you which one it picked. --region picks the Bedrock region (default us-east-1 or your AWS_REGION).

With no flag, caprock wrap claude auto-detects from your environment:

Your setup What happens
CLAUDE_CODE_USE_BEDROCK=1 signs Bedrock with your creds
ANTHROPIC_API_KEY set routes to the Anthropic API
Neither Bedrock (the default)
Plain Claude subscription (Pro/Max, no env key) add the flag: caprock wrap claude --anthropic — auto-detect reads env vars and can't see a subscription yet

The backend and profile are baked in when the proxy starts. If a caprock proxy is already running (another wrapped session), your flags apply only once it's gone — exit the other session, or use a different --port.

Tip: alias claude='caprock wrap claude' (add --anthropic if you're on a subscription) — every session runs through caprock. Sessions started without wrap bypass caprock entirely.

Anything after caprock wrap claude that isn't a caprock flag (--bedrock, --anthropic, --profile, --region, --port) is passed straight through to Claude Code itself, so its normal flags work unchanged, e.g.:

caprock wrap claude --dangerously-skip-permissions
caprock wrap claude --bedrock --profile work --dangerously-skip-permissions
caprock wrap claude --resume

Never run caprock wrap with sudo — it doesn't need root, and running it once as root can leave ~/.caprock files owned by root that your normal user can no longer write to.

Every session ends with the money you saved:

💰 You've saved $19.20 with caprock
   6,400,000 tokens cut · −85% input cost · 40 requests
   this month: $19.20 so far → ~$74/mo at this pace

Measured live against real Bedrock: −48% billed input on a clean install, −59.7% re-confirmed on a six-turn agent session, up to −70% with the full pipeline. On the direct Anthropic API (compression only — caching already works there): up to −55% on tool-heavy JSON. Your number will vary with your workload — run caprock measure to see yours. How we got these: https://caprock.dev/methodology.

What it does

  • Compression — shrinks tool outputs / logs / JSON before they reach the model.
  • Prompt caching — makes Bedrock's prompt cache actually engage (stock Headroom's markers die in conversion → 0% on Bedrock; caprock fixes that).
  • Savings metercaprock stats and the end of every wrap session show what you saved, computed locally from real Bedrock cache tokens.
  • Runs on localhost, signs with your Bedrock credentials. No caprock service in the request path — nothing leaves your machine.

Commands

Command What it does
caprock wrap claude Runs Claude Code through the local proxy on your own creds
caprock start Starts the proxy on its own (point any client at it)
caprock stats Shows what you've saved (cache + compression, all time)
caprock measure Replays a workload direct vs through caprock — your own number
caprock dashboard Opens the local savings dashboard

Team?

Running Claude across a team? The managed tier is a shared in-VPC gateway with per-user / per-role cost attribution, a team dashboard, deployment and support — deployed inside your own AWS account, nothing leaves your VPC. Pricing and a 20-min call: https://caprock.dev/pricing.

Built on Headroom

caprock builds on the open-source Headroom project (Apache 2.0). It applies the general-purpose fixes that make caching and compression work on AWS Bedrock (contributed back upstream) over the stock headroom-ai package. Licensed Apache-2.0.

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

caprock-0.1.9.tar.gz (97.1 kB view details)

Uploaded Source

Built Distribution

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

caprock-0.1.9-py3-none-any.whl (90.3 kB view details)

Uploaded Python 3

File details

Details for the file caprock-0.1.9.tar.gz.

File metadata

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

File hashes

Hashes for caprock-0.1.9.tar.gz
Algorithm Hash digest
SHA256 22f7e02e5d1fa82efe3f0e993fccc552bafa9986f53429da8e80fdcfe1091ed0
MD5 bebe7639ba1f610cde830f8774d8b7b1
BLAKE2b-256 666735a8508d39366a8ec3793ba945597e26f32cc5e5abb1b74f2a322d8b8877

See more details on using hashes here.

File details

Details for the file caprock-0.1.9-py3-none-any.whl.

File metadata

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

File hashes

Hashes for caprock-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 898ab04f9fb5a8fb23538718cea2c8a21165be0c0d4d0c73a00acd08089ca597
MD5 84049757b0a1fecf92843c1699719f5d
BLAKE2b-256 9d9c47dc005de0cf2c1e54c140c82e3d68936e87b7cb88a48ae537c0f042a6cc

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