ForkFree

Developer tools

leanctx

by jia-gao

leanctx is a Python library that shortens the text you send to AI models, so each request uses fewer tokens and costs less. It works as a replacement for the OpenAI, Anthropic or Gemini client and leaves code, JSON and tool calls untouched while compressing prose.

Worth a lookEstablished, with a few things to check (listed below).

View on GitHub

Stars
321
Licence
MIT
Runs on
Your computer
Setup
Moderate
Language
Python
Age
194 days

What you can do with it

  • Swap in the leanctx client for the OpenAI, Anthropic or Gemini client to compress long prompts automatically
  • Shorten retrieved documents, logs and chat history in RAG apps and agents before they reach the model
  • Check how many tokens each request saved using the usage figures returned with every response

Make money with it

A freelancer could offer an LLM cost-reduction audit for small companies, using leanctx to cut their API spend and charging a fee or a share of the savings.

An idea, not financial advice. Check the licence before charging for anything built on it.

Ways a business could use it

  • Lower the monthly API bill of a customer-facing chatbot or document-processing tool by compressing long inputs
  • Keep a long-running support or coding agent affordable as its conversation history grows

Can you use it commercially?

Free to use, change and sell, including in paid products. Keep the copyright notice.

Not legal advice. Read the project's licence file before building a product on it.

Getting it running

Install with pip (for example pip install 'leanctx[openai,lingua]'), then change your import to use the leanctx client; the first run downloads about 1.2 GB of model weights.

Follow the official instructions in the project README.

Things to check

  • Compression costs some accuracy (1.8 percentage points overall in the benchmark, and more on some task types)
  • You still need a paid API key from your model provider
  • Runs a roughly 1.2 GB model locally; a GPU is advised for low latency
  • Savings claims vary between the headline (40-60%) and the README body (10-40%), so test on your own traffic

Who's talking about it

Checked 29 Oct 2026. Summary drafted by AI from the project's README.

More in Developer tools

gpu-unlock Zagitta
Check the licence

This tool unlocks the FP/BF16 instruction issue rate on Nvidia 3000-series cards, doubling the speed of certain operations.

13.3k stars +986 a day Unclear
graphify Graphify-Labs
Worth a look

Graphify turns a codebase, along with its documents, PDFs, SQL schemas and configuration files, into a graph of connected concepts that you can search and question. It works as a /graphify command inside AI coding assistants such as Claude Code, Cursor, Codex and Gemini CLI, so they can look things up in the graph instead of reading every file.

139k stars +746 a day Apache-2.0
taste-skill Leonxlnx
Worth a look

Taste Skill is an add-on for AI coding agents such as Claude Code, Codex and Cursor. It guides the agent to design more distinctive websites and app screens by choosing an art direction, using credited real photographs and checking its own work in a real browser.

105.8k stars +730 a day MIT