Open SourceMIT License

badgr-auto

A local OpenAI-compatible proxy that removes duplicate tokens, routes requests to the cheapest available model, and logs your savings — all on your machine.

How it works

badgr-auto sits between your coding tool and your AI provider. It cuts costs twice: fewer tokens sent, cheaper model chosen.

1

Token optimisation

Deduplicates repeated context and compresses long conversation history before forwarding. Typically removes 20–50% of tokens.

2

Smart routing

Short autocomplete tasks go to a free local model. Normal queries go to a cheap OSS cloud model. Only complex tasks hit premium models.

3

Savings log

Every request is logged locally. Run badgr-auto stats to see tokens saved and what you would have paid with Haiku or Sonnet.

1

Install

Terminal
npm install -g badgr-auto

Requires Node.js ≥ 20.

2

Start the proxy

Terminal
badgr-auto start

The guided setup detects your hardware, finds running local models (Ollama / LM Studio), and optionally connects your AI Badgr account for cloud routing.

The proxy starts at http://localhost:51999/v1.

3

Connect your tool

Point any OpenAI-compatible tool at the proxy. Use your AI Badgr API key (or any non-empty string for local-only mode).

Base URL

http://localhost:51999/v1

Model

badgr-auto

What you see after each request

badgr-auto logs two savings comparisons to stderr after every request — token optimisation and routing.

Terminal output
✓ Routed: local model
✓ Tokens: 8,420 → 5,960 (−2,460 tokens, 29%)
✓ Cloud cost: $0.00
✓ Estimated saved vs Claude Haiku:  $0.0048
✓ Estimated saved vs Claude Sonnet: $0.0179
✓ Latency: 142ms

For cloud routes, Actual cost is shown instead of Cloud cost: $0.00.

View your savings

Terminal
badgr-auto stats       # all time
badgr-auto stats 7d    # last 7 days
badgr-auto stats 1d    # last 24 hours
Example output
  Estimated savings — Last 7 days

  Token optimisation

  Requests:                  1,240
  Original tokens:           4.92M
  Optimized tokens:          2.94M
  Tokens removed:            1.98M
  Average context reduction: 40.4%

  Routing savings

  Actual cost:               $8.70

  Cost using Claude Haiku:   $28.10
  Cost using Claude Sonnet:  $56.90

  Saved vs Claude Haiku:     $19.40
  Saved vs Claude Sonnet:    $48.20

  Requests routed:
    Local:                   38%
    OSS cloud:               52%
    Premium:                 10%

Routing tiers

badgr-auto routes each request to one of four tiers based on task complexity, prompt length, and available endpoints.

TierWhereUsed forCost
edgeLocal (Ollama / LM Studio)Autocomplete, formatting, small edits$0.00
midOSS cloud modelRefactor, summarise, normal chatLow
asyncBackground GPUEmbeddings, indexing, batch evalLow
premiumPremium model (Claude etc.)Deep debugging, critical outputStandard

Override the tier for a request by passing badgr_task_type in the request body (e.g. "badgr_task_type": "autocomplete").

Open source

Everything that runs on your machine is open source under the MIT licence. You can read the code, audit what happens to your prompts, and contribute.

OpenAI-compatible local proxy
Ollama / LM Studio auto-detection
Streaming passthrough
Context deduplication
Safe compression rules
Token counter
Local savings log (SQLite)
badgr-auto stats command
Configurable routing tiers
Cline / Continue / Aider guides
View on GitHub →

Commands

badgr-auto startStart the proxy. Runs guided onboarding on first use.
badgr-auto stopStop the running proxy.
badgr-auto statusShow whether the proxy is running and which port.
badgr-auto stats [1d|7d|all]Print token savings and routing breakdown for the given period.
badgr-auto modelsList models available through the proxy.
badgr-auto loginConnect your AI Badgr account to unlock cloud routing.

Ready to cut your AI spend?

Install badgr-auto in two minutes. No account needed for local routing.