Skip to main content

Drop-in prompt compression for production LLM applications. Cut Anthropic / OpenAI / Gemini bills by 40-60%.

Project description

leanctx

Drop-in prompt compression for production LLM applications. Cut Anthropic / OpenAI / Gemini bills by 40–60% without changing your code.

# before
from anthropic import Anthropic

# after
from leanctx import Anthropic  # same interface, compressed requests

Open-source models. No API keys to anyone but your existing provider. Your prompts and user data never leave your infrastructure by default.


Status: v0.0.0 — name reservation. v0.1 (working release) coming in ~4 weeks. Watch the repo to be notified.

Who this is for

You're building a production LLM app and your token bill is a line item:

  • RAG apps with large retrieved documents
  • Long-running conversational agents
  • LangChain / LangGraph / CrewAI workflows with growing tool chains
  • Document-processing pipelines
  • Anything where input tokens accumulate and you pay for every one

If your code calls anthropic.messages.create() or openai.chat.completions.create() in production, this is for you.

How it works (coming in v0.1)

Three compression modes, one config switch:

  • local — runs Microsoft's open-source LLMLingua-2 locally. Free marginal cost.
  • self_llm — lets your own configured LLM do the compression. Highest quality.
  • hybrid (default) — routes by content type: code stays verbatim, prose goes through LLMLingua-2, long important spans fall back to self_llm.

Content-aware routing means code blocks, diffs, stack traces, and tool schemas are preserved verbatim — no corrupted syntax.

Roadmap

  • v0.1 — Python SDK, local mode (LLMLingua-2), Anthropic + OpenAI drop-in clients
  • v0.2 — self_llm mode, Gemini client, LangChain / LlamaIndex integrations
  • v0.3 — TypeScript SDK, Docker image, OTel observability
  • v0.4 — Helm chart, Kubernetes sidecar deployment

Install (placeholder)

pip install leanctx  # not yet functional — reservation only

Credits

Architecturally inspired by OpenCode DCP (AGPL-3.0, not copied). leanctx is a clean-room implementation under MIT.

Ships Microsoft's LLMLingua-2 (MIT).

License

MIT. See LICENSE.

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

leanctx-0.0.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

leanctx-0.0.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file leanctx-0.0.0.tar.gz.

File metadata

  • Download URL: leanctx-0.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.3

File hashes

Hashes for leanctx-0.0.0.tar.gz
Algorithm Hash digest
SHA256 b791af49db455fb0010bfd05c359f8e76d382fe63eec24fe8e923471953eb428
MD5 8d00656480fdbbcceecf73dd2b8f4224
BLAKE2b-256 99cb69f4495778be940307b92a8eb571b0e2a4cc5c0943c1ec1b9fba6dd06205

See more details on using hashes here.

File details

Details for the file leanctx-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: leanctx-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.3

File hashes

Hashes for leanctx-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c848ba71e36e92a44196f11649e311c3dc50d53073fb926a8e2a4da3f60cbf3
MD5 c6b4720de35ebec5aa1ddcd84b265c82
BLAKE2b-256 c6152695b1198b982018c8ae2fa5ee1a10167b5238fa3b6252af72c357aec913

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