llmtrim CLI
A local Rust proxy that compresses the model API requests of Claude Code, Codex and Cursor so you pay for fewer tokens
- 267 ★ on the repository
- Last commit
- MPL-2.0
Broad access
Why this level
- The proxy decrypts and rebuilds all model API traffic on your machine, including prompts, code and authorization headers
- Setup creates a private root certificate, changes shell variables and installs a service that starts at login
- Compression changes what the model sees: trimmed parts of the request never reach it, although the author says the answer stays the same
Install
- Works in
Manual install
npm install -g @llmtrim/cli@latest && llmtrim setupAfter installing open a new terminal and check `llmtrim status`. Use `llmtrim update` to upgrade.
Access and checks
How we reviewBroad accessThe tool can change data, run commands or handle secrets.
- The proxy decrypts and rebuilds all model API traffic on your machine, including prompts, code and authorization headers
- Setup creates a private root certificate, changes shell variables and installs a service that starts at login
- Compression changes what the model sees: trimmed parts of the request never reach it, although the author says the answer stays the same
This is third-party code. Review the repository files before installing.
What it does
llmtrim runs on your machine as a proxy between the agent and the provider API. On every turn the agent sends a large request: system prompt, tool descriptions, history, raw command output. llmtrim cuts the waste and forwards a smaller request, and the reply arrives unchanged. Any tool that honors the `HTTPS_PROXY` variable works without changes. Compression has ten stages. Build logs, diffs and search dumps are reduced to errors, changes and matches, and repeated lines fold into a template with values. Long pasted context is cut down to chunks relevant to the question. Source code stays as signatures except for useful function bodies (parsing for 14 languages). Tool descriptions are trimmed so the stable cache prefix does not change. Large JSON arrays collapse into a table or a sample, duplicates are removed, and the model can be asked to answer tersely. llmtrim re-measures each stage with the provider tokenizer and undoes it if tokens did not drop. If the provider rejects a compressed request, the original goes out. The same engine is available as the `llmtrim compress` command, as an MCP server (`llmtrim_compress`, `llmtrim_compress_text`, `llmtrim_stats`) and as a library for Python, Ruby, Kotlin, Swift and JS/TS. `llmtrim status` shows the savings, and there is a system tray icon.
Who it is for. For developers who work a lot with Claude Code, Codex or Cursor on an API key and want a smaller token bill without changing their tools.
Good fit when
- Your agent sends long build logs or test outputs every turn and the real errors are two or three lines
- The descriptions of dozens of MCP tools are resent with every call and you want to trim them while keeping the prefix cache
- Requests contain big JSON arrays and many duplicate lines
- You want one savings layer for several clients that honor `HTTPS_PROXY`: Claude Code, Codex CLI, Gemini CLI, Aider and your own SDK
- You want to compress requests from your own app through the library or command line without installing a proxy
Not a fit when
- You use GitHub Copilot: it pins certificates and does not pass through the proxy
- You cannot change shell environment variables or install a local root certificate on the work machine
- You pay for the agent with a flat subscription with no per-token billing, so savings give you nothing
- You only need a usage counter and must not touch requests: a passive monitor is enough
Example request
Install llmtrim, run llmtrim setup and a day later show how many tokens were saved in Claude Code according to llmtrim statusLimitations
The `llmtrim setup` command makes three changes: it creates a private certificate authority in `~/.llmtrim/`, adds `HTTPS_PROXY` and certificate trust to the shell, and installs a service that starts at login. The certificate is constrained to LLM provider hostnames. `llmtrim uninstall` reverses all three steps. The proxy stores no API keys and writes no requests to disk; only anonymous token counts remain. Recoverable tool results stay in daemon memory for up to five hours and disappear on restart.
GitHub Copilot is not supported by the proxy. The optional `sub` feature reroutes Claude Code through the third-party CLIProxyAPI, the author warns it may conflict with provider terms, and while it is on, claude.ai connectors stop working. This card neither describes nor recommends that feature. The license is MPL-2.0.
How to disable. Run `llmtrim uninstall`: it removes the private certificate, the shell variables and the login service. If you only need a pause, `llmtrim stop` is enough and `llmtrim start` brings the proxy back.
FAQ
How do I install llmtrim?
Run `npm install -g @llmtrim/cli@latest && llmtrim setup`, open a new terminal and check `llmtrim status`. Other routes exist: `brew install fkiene/tap/llmtrim`, `cargo binstall llmtrim`, `scoop install llmtrim`, install scripts for Linux, macOS and Windows, and a Docker image.
Is it safe and what does setup change?
The proxy works like mitmproxy but only for LLM provider hosts. It creates a name-constrained private certificate authority, adds `HTTPS_PROXY` and certificate trust to the shell and installs a login service. You can verify the constraint with `llmtrim ca` and `openssl x509 -in ~/.llmtrim/ca.pem -noout -text`.
Can compression break a request or raise the bill?
The author says no. After each stage tokens are re-measured with the provider tokenizer and a stage with no gain is undone. A request the provider rejects is resent in its original form, so the worst case is zero savings.
How do I use llmtrim as an MCP server?
The `llmtrim mcp install` command configures Claude Code, and `llmtrim mcp install --print` prints a block for any client: `{"mcpServers": {"llmtrim": {"command": "llmtrim", "args": ["mcp"]}}}`. The server tools are `llmtrim_compress`, `llmtrim_compress_text` and `llmtrim_stats`.
What if something breaks after an update?
Run `llmtrim ensure` to bring the install to the recommended state, or `llmtrim doctor --fix` to diagnose and repair. The `llmtrim update` command updates the release and restarts the daemon.
Discussion
No questions or reviews yet.
Related
CLI toolsThe CLI starts a language-model proxy and a request tracking service for debugging applications across model providers.
Token Optimizer
token-optimizer
A plugin for Claude Code and Codex: trims wasted tokens, keeps work alive across sessions and compactions and shows cost. The license is noncommercial
Tokscale
tokscale
A CLI with an interactive TUI that tracks token usage and cost across AI coding agents: Claude Code, Codex, Copilot, Cursor and more
Local proxy between Claude Code and Anthropic that fixes prompt-cache misses, stabilizes the request prefix and shows quota use in the status line
Shows what Claude Code and Codex actually send to the API: it captures local traffic and splits tokens and cost by source
A local proxy between AI agents and model providers that prices every run as it happens and cuts off spend above your cap
Comparison with similar tools
Cards that share the main search query, and how they differ.
| Tool | Official | Repository stars | Main difference |
|---|---|---|---|
| llmtrim (this card) | no | 267 | |
| RTK | no | 85,720 | a Rust CLI proxy that compresses the output of git, tests and other commands |
| Claude Token Optimizer: fewer tokens at startup | no | 644 | a utility that counts the tokens Claude Code loads at start and trims them |
README in short
The author claims, over 112 live comparisons, 31% fewer input tokens, 74% fewer output tokens, about 5 ms per call and no model to load. The document has an example compressing a build log from 4,662 to 978 characters, client compatibility tables and the `auto` and `safe` mode configuration. A system tray icon and bindings for six languages ship alongside.