Slash LLM costs with intelligent context compression, smart routing, and cost tracking
Project description
TokenPak — Cut your LLM token spend by 30–50%, zero config
TokenPak is a local proxy that compresses your LLM context before it hits the API — fewer tokens, lower cost, same results. No code changes, no cloud, no credentials stored.
Status: early preview. Core compression engine and proxy are in place. Per-client auto-integration (the
tokenpak integratecommand) is not yet shipped — configure your client manually by pointing it athttp://127.0.0.1:8766. See QUICKSTART at https://github.com/tokenpak/docs (rendered at tokenpak.ai/quickstart).
Quick start
pip install tokenpak
tokenpak start # start the local proxy at 127.0.0.1:8766
Point your LLM client at the proxy. For example, the Anthropic SDK:
export ANTHROPIC_BASE_URL=http://127.0.0.1:8766
Or for OpenAI-compatible clients:
export OPENAI_BASE_URL=http://127.0.0.1:8766
Then use your client normally. TokenPak compresses requests on the way out and logs savings to a local SQLite ledger.
See QUICKSTART at https://github.com/tokenpak/docs (rendered at tokenpak.ai/quickstart) for per-client setup (Claude Code, Cursor, Aider, and others).
What savings look like
After a few proxied requests, tokenpak savings reports the cumulative reduction:
┌──────────────────────────────────────────────────────┐
│ TokenPak — Savings │
├──────────────────────────────────────────────────────┤
│ Sample scenario DevOps agent (config + logs) │
│ Savings drivers dedup + alias │
├──────────────────────────────────────────────────────┤
│ Original 747 tokens │
│ Compressed 502 tokens │
│ Saved 245 tokens (32.8%) │
│ Cost saved (est.) $0.00073 per call │
├──────────────────────────────────────────────────────┤
│ Stages: dedup, alias, segmentize, directives │
└──────────────────────────────────────────────────────┘
Actual numbers depend on your workload. Agent-style prompts with lots of repeated context see the biggest gains.
Works with
Any LLM client that respects a custom base URL:
Claude Code · Cursor · Cline · Continue.dev · Aider · OpenAI SDK · Anthropic SDK · LiteLLM · Codex
Per-client configuration steps are in QUICKSTART at https://github.com/tokenpak/docs (rendered at tokenpak.ai/quickstart). Auto-wiring via a single tokenpak integrate <client> command is tracked for a future release.
Install
pip install tokenpak
TokenPak's runtime dependencies include anthropic, openai, fastapi, flask, litellm, llmlingua, pandas, pydantic, requests, rich, scipy, sentence-transformers, tree-sitter-languages, watchdog, and a few others — all installed automatically. Note that sentence-transformers and scipy are large (several hundred MB of dependencies); expect pip install to take a few minutes on first install.
Requires Python 3.10+.
See QUICKSTART at https://github.com/tokenpak/docs (rendered at tokenpak.ai/quickstart) for virtual-env setup and first-run details.
What's included
- Context compression — deterministic pipeline (dedup → alias → segmentize → directives); typical 30–50% token reduction on agent workloads.
- Local proxy — runs at
127.0.0.1:8766; zero cloud component. - Model routing — configurable rules with fallback chains.
- Cost & savings tracking — per model, per session, per agent; local SQLite (
~/.tokenpak/monitor.db). - Dashboard — local web UI for visualizing savings (
tokenpak dashboard). - Vault indexing + semantic search — index a directory; search without an LLM call.
- A/B testing and request replay — compare compression configs; re-run past requests.
- 50 built-in compression recipes — YAML, customizable.
See QUICKSTART at https://github.com/tokenpak/docs (rendered at tokenpak.ai/quickstart) and API reference at https://github.com/tokenpak/docs (rendered at tokenpak.ai/api) to get started.
Current limitations
Honest about what isn't ready yet:
- No
tokenpak integrate <client>auto-wire command — configure clients by env var as shown above. Auto-wire is planned. - No published CI/CD — releases are manual; automation is tracked in the release-workflow standards.
tokenpak demois a compression-recipes demo (shows recipes applied to a sample input), not the decorated savings panel above. The panel shows whattokenpak savingsoutput can look like after real usage.
We'd rather ship an honest preview than an advertised product that doesn't match install-time reality.
Support
- Docs: QUICKSTART at https://github.com/tokenpak/docs (rendered at tokenpak.ai/quickstart) · API reference at https://github.com/tokenpak/docs (rendered at tokenpak.ai/api) · FAQ at https://github.com/tokenpak/docs (rendered at tokenpak.ai/faq)
- Issues: github.com/tokenpak/tokenpak/issues
- Discussions: github.com/tokenpak/tokenpak/discussions
- Email: hello@tokenpak.ai
License
Apache 2.0. See LICENSE.
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 tokenpak-1.2.8.tar.gz.
File metadata
- Download URL: tokenpak-1.2.8.tar.gz
- Upload date:
- Size: 1.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7171d63ac4d63edd484b9f50a8998018ab1a758bf2d6ae6e5b96939b4fa8bd72
|
|
| MD5 |
d45931037b9f204c160752cc4715c127
|
|
| BLAKE2b-256 |
5b57cfbcd403bba7d37572d0602e7d0e82adcb7e5fced7661780d18e01244336
|
File details
Details for the file tokenpak-1.2.8-py3-none-any.whl.
File metadata
- Download URL: tokenpak-1.2.8-py3-none-any.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4bb068c108f55c2f70ffa6b65871477bc32614e25d32845f37b9572b956c7ad
|
|
| MD5 |
1f743324b6a03df7fc4fbcdae52563c0
|
|
| BLAKE2b-256 |
1792c783e90827bbbbf9f84f5facefeda1e2b6751a2337f80f74294d55bd5bbc
|