Skip to main content

Local-proxy CLI for mintoken — sit between Claude Code / Codex and the upstream LLM, dedupe + truncate context, save 40-70% on long agent sessions.

Project description

mintoken-cli

Local-proxy for Mintoken. Sit between your AI coding tool (Claude Code, Codex, Cursor, your own LangChain agent) and the upstream LLM provider. Dedupe repeated tool results, truncate giant logs, save 40-70% of input tokens on long agent sessions. Same model output, no SDK changes, one env var swap.

Why

Modern AI coding agents loop. Every turn re-sends the entire prior conversation. After 20 turns of file reads + bash output + grep results, you're paying to re-send the same content over and over — typically 90% of your bill is cache reads of stale context.

Mintoken-cli sits on localhost, intercepts your agent's HTTPS traffic to the LLM provider, dedupes redundant tool results in older turns, truncates the boring middle of giant logs — then forwards what's left to the real provider. Anthropic / OpenAI bill you for the smaller request.

Install

pip install mintoken-cli

Or from source:

git clone https://github.com/vijayPrajapatii/mintoken
cd mintoken/mintoken-cli
pip install -e .

Setup

# (optional) save your mintoken key so the dashboard tracks savings
mintoken login --key mt_live_...

# start the local proxy
mintoken proxy

You'll see:

mintoken-cli v0.1.0
listening on  http://127.0.0.1:8788
level         standard
mintoken key  mt_live_da7a…
anthropic →   https://api.anthropic.com
openai →      https://api.openai.com

Use with Claude Code

# PowerShell
$env:ANTHROPIC_BASE_URL = "http://127.0.0.1:8788"
claude
# bash / zsh
export ANTHROPIC_BASE_URL="http://127.0.0.1:8788"
claude

Your existing Claude Code OAuth session keeps working — the proxy forwards the auth header unchanged. The OAuth token never leaves your machine.

Use with Codex / OpenAI clients

$env:OPENAI_BASE_URL = "http://127.0.0.1:8788/v1"
codex
export OPENAI_BASE_URL="http://127.0.0.1:8788/v1"
codex

Or with the OpenAI SDK directly:

from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8788/v1", api_key="sk-...")

Use with both at once

The proxy handles both providers on the same port. Set both env vars and run Claude Code + Codex side by side — they share the same proxy.

Flags

mintoken proxy [OPTIONS]

  --port              -p   default: 8788
  --host                   default: 127.0.0.1
  --key                    mintoken API key (or set MINTOKEN_KEY env)
  --level             -l   light | standard | aggressive  (default: standard)
  --anthropic-upstream     default: https://api.anthropic.com
  --openai-upstream        default: https://api.openai.com

Compression levels

Level Min tokens to engage Tool-result truncate threshold Recency window (untouched)
light 8,000 4,000 last 8 turns
standard (default) 4,000 2,000 last 6 turns
aggressive 2,000 1,000 last 4 turns

Aggressive saves the most but compresses content the model might still need. Light is conservative. Standard is the production default and is what we'd recommend for nearly everyone.

What gets compressed

Dedupe — when the same tool_result content appears multiple times in older turns (e.g., your agent re-reads the same file 3x), the earliest copies are replaced with a small back-reference. Only the latest occurrence stays verbatim.

Truncate — when a single tool_result is bigger than the per-result threshold (e.g., a 4,000-token build log), the head + tail are kept and the middle is dropped with a marker.

What is never touched

  • The system prompt
  • The most recent N messages (recency window)
  • Mid-flight tool_use / tool_result pairs
  • Any conversation under the min-tokens threshold

If compression somehow produces a bigger body, the original is forwarded untouched. Never increases your bill.

Verify it's working

The proxy attaches three response headers to every forwarded request:

x-mintoken-cli-tokens-before: 9027
x-mintoken-cli-tokens-after:  2947
x-mintoken-cli-tokens-saved:  6080

You can also visit your dashboard at https://mintoken.dev/dashboard — savings flow there in real time (provided you've set --key).

Privacy

  • Auth tokens (OAuth or API key) are forwarded unchanged through localhost. They never leave your machine.
  • Request bodies are compressed locally, in memory. We never log or store prompts.
  • The only thing that goes to api.mintoken.dev is a small metric record per request: model name, token counts, duration. No content. No headers. No prompts.
  • If you don't set --key, no telemetry is sent at all — fully local mode.

License

MIT.

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

mintoken-0.1.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

mintoken-0.1.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file mintoken-0.1.0.tar.gz.

File metadata

  • Download URL: mintoken-0.1.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for mintoken-0.1.0.tar.gz
Algorithm Hash digest
SHA256 842c0612f2fa59099b3630305cae05a0c0b932976e3e7728ed2116ce468ab141
MD5 1f151fdb36f0af92156bd42f34754611
BLAKE2b-256 177cf6b871e374ff0a1d844363860dbd3cf495dda92f757813292c9aca96776a

See more details on using hashes here.

File details

Details for the file mintoken-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mintoken-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for mintoken-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3bbb271cae51a4a39f50bba363b0324d4abc34850a205bbcb8a124a60f12f997
MD5 395296660d5ded3a625e268c7b597ad4
BLAKE2b-256 7cfc02b80de259c40d2c83673c655869b8668498765eabd08ae7bbf671c5e9e9

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