Show HN: Frugon – 找出哪些 LLM 调用可以改用更便宜的模型处理(本地运行,MIT 协议)
Show HN: Frugon – Find which LLM calls a cheaper model could handle (local, MIT)

原始链接: https://github.com/Rodiun/frugon

**Frugon** 是一款免费、本地化且开源的工具,旨在通过检查您的实际调用日志来分析并优化大语言模型(LLM)的成本。由于它完全在您的机器上运行,您的数据和 API 密钥将始终保持私密,绝不会与第三方共享。 **工作原理:** * **捕获:** 使用 `frugon capture` 作为本地代理,将应用程序的 LLM 流量记录为 JSONL 日志。您也可以直接提供现有的日志文件。 * **分析:** 运行 `frugon analyze` 以生成详细的成本分析报告。该工具会将您当前的支出与各种模型替代方案进行比较,识别出哪些调用可以在不牺牲性能的前提下转向更便宜的模型。 * **评估:** 您可以选择使用 `--measure` 标志,利用您自己的供应商密钥针对真实流量对候选模型进行测试,确保在切换之前维持高质量表现。 Frugon 提供清晰且可操作的建议,例如“将困难任务保留在当前模型,将简单任务转移到更经济的模型”,从而帮助您显著节省每月的 LLM 开支。该工具轻量化,能快速处理超过 10 万条记录,并支持输出用于预算审查的专业报告。 如需持续、自动化的路由功能,请访问 [frugon.rodiun.io](https://frugon.rodiun.io)。

**Frugon** 是一款全新的本地命令行工具,旨在通过识别哪些大模型(LLM)调用可以使用更廉价的模型来处理(且不牺牲质量),从而帮助用户降低 AI Token 成本。 该工具由用户 *jarodrh* 开发,通过分析本地 OpenAI 风格的日志,基于 LMArena 的质量分级提供节省成本的建议。它完全在本地运行,也可选择使用本地代理,并确保在分析过程中没有任何数据流向外部端点。 该工具具备三大核心功能: 1. **分析(Analyze):** 通过对比当前使用情况与更廉价模型的差异,估算潜在的每月成本节省额。 2. **衡量(Measure):** 并排展示不同模型处理相同提示词(Prompt)和回复(Response)的输出结果。 3. **评估(Judge):** 使用选定的大模型来对比候选模型与当前模型的性能,并采用倾向于“平局”的提示词模板,以确保输出结果在功能上等效。 通过将成本分析与“以大模型为裁判(LLM-as-a-judge)”的验证循环相结合,Frugon 能够帮助开发者超越简单的削减成本,确保路由决策能够维持其特定任务所需的质量标准。该工具开源(MIT 协议),可通过 `uv` 安装。
相关文章

原文

Your LLM bill is leaking — see exactly where, on your machine.

Free, local, open-source LLM cost analyzer. Point Frugon at your LLM call logs and see — on your machine — how much you'd save by switching or routing models.

PyPI License: MIT CI Python Platforms

Your data never leaves your machine. Your keys go straight to your own providers. Nothing reaches us.

Frugon analyzing a log file and recommending a routing split

# one-shot (no install)
uvx frugon analyze ./logs.jsonl

# permanent install
pipx install frugon
frugon analyze ./logs.jsonl

# for --measure (optional): samples real prompts through your own provider keys
pip install 'frugon[measure]'
frugon analyze ./logs.jsonl --measure

No logs yet? See Getting your logs below, or run frugon analyze --demo to see it work on a bundled sample.

frugon reads JSONL files in the OpenAI request/response format. There are two ways to produce them.

Option A — frugon capture (proxy shim)

frugon capture is a local HTTP proxy that sits between your app and your provider. Every call is forwarded unchanged to your real provider and saved as one JSONL line.

# Start the shim (default port 8787, output file capture.jsonl)
frugon capture --out ./logs.jsonl

# Then point your app's base URL at the shim instead of api.openai.com:
OPENAI_BASE_URL=http://127.0.0.1:8787 your-app           # bash / zsh
$env:OPENAI_BASE_URL="http://127.0.0.1:8787"; your-app   # PowerShell (Windows)
# or in code: client = OpenAI(base_url="http://127.0.0.1:8787/v1")

Options: --port, --out, --upstream (override the forwarding target), --verbose (print one line per captured call to verify it's recording), --proxy (opt in to route upstream calls through a proxy — by default frugon ignores any ambient HTTP_PROXY / HTTPS_PROXY, so your API key never passes through a third-party proxy). The shim adds no latency overhead on localhost and makes no calls to any frugon endpoint.

Option B — write JSONL directly

If you already capture logs (e.g. via middleware or a provider SDK callback), write one JSON object per line with this shape:

{
  "model": "gpt-4-turbo",
  "request": {
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user",   "content": "Summarise this document: ..."}
    ]
  },
  "response": {
    "choices": [{"message": {"content": "Here is the summary: ..."}}]
  },
  "usage": {
    "prompt_tokens": 312,
    "completion_tokens": 84
  },
  "timestamp": "2024-11-01T14:22:01Z"
}

usage.prompt_tokens / usage.completion_tokens — preferred when present; frugon falls back to its own tokenizer when absent. timestamp is optional but enables frugon to project costs over a real observed span. model is required; everything else degrades gracefully.

5-minute path from install to first analysis

uv tool install frugon          # or: pipx install frugon / pip install frugon
frugon capture --out ./logs.jsonl &   # start the proxy in the background
# ... run your app, make some LLM calls ...
frugon analyze ./logs.jsonl     # see the cost breakdown and routing recommendation
  • Cost analysis — fully local, no LLM calls, no network. Tokenizers + pricing + arithmetic on your machine.
  • Quality visibility (--measure, optional) — samples your traffic through candidate models using your own API keys, sent directly to your own providers. Never to us. --measure needs pip install 'frugon[measure]' and a provider API key (OPENAI_API_KEY, etc.); calls go to your own provider, never to us. On --demo, sampling is pinned to a single OpenAI model so the try-out needs only OPENAI_API_KEY; on your own logs, --measure samples the actual recommendation.
  • Routing recommendation — "move these X% of calls to a cheaper model and save ~$Y/mo; keep the hard Z% where they are." Comes with an explicit quality caveat so you know what you're trading. Run frugon models to see the model names available for --candidates (optionally frugon models gpt-4o to filter by substring).
  • Share the result — add --report savings.html (or .md) to write a clean, shareable report you can drop into a PR, a Slack thread, or a budget review.
  • Fast on real logs — everything runs locally and is comfortable well past 100k records. The bundled ~56,100-call demo (frugon analyze --demo) prices in a few seconds. Very large logs (>200k records) may take a little longer; Frugon shows a live progress bar and a one-line heads-up so you can see it working. There's no hard limit.
$ frugon analyze --demo --candidates claude-sonnet-4-5,gpt-4.1,claude-haiku-4-5,gemini-2.5-flash,deepseek-v4-flash

┌─ frugon · cost analysis ────────────────────────────────────────────────────┐
│                                                                             │
│   Analyzed      56,100 calls  ·  baseline gpt-5.5 (your current model)      │
│   Current spend $549.46 / mo                                                │
│                                                                             │
│     Route  36,100 easy calls (64.4%)  →  deepseek-v4-flash   within         │
│   tolerance                                                                 │
│     Keep   10,000 hard calls (17.8%)  →  gpt-5.5                            │
│     Keep   10,000 already on deepseek-v4-flash (17.8%)   already optimal    │
│   — no action                                                               │
│                                                                             │
│   New spend     $343.91 / mo                                                │
│                                                                             │
│   SAVING        $205.55 / mo    ·    37.4% lower                            │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘
                                                                               
  Candidates considered                                                        
  claude-sonnet-4-5  $452.23 / mo  17.7% lower  Strong   considered            
  gpt-4.1            $405.89 / mo  26.1% lower  Capable  considered            
  claude-haiku-4-5   $377.82 / mo  31.2% lower  Capable  considered            
  gemini-2.5-flash   $356.35 / mo  35.1% lower  Strong   considered            
  deepseek-v4-flash  $343.91 / mo  37.4% lower  Strong   recommended           
  Each candidate is shown under the same quality-preserving split (easy calls  
  to the candidate, hard calls kept on baseline); the biggest saving is the    
  headline recommendation, and when savings tie at the precision shown the    
  higher quality tier wins. Run --measure --judge to score each candidate's    
  quality.                                                                     

  Accounting   36,100 routed + 10,000 kept (gpt-5.5) + 10,000 already on 
               cheaper deepseek-v4-flash  =  56,100 analyzed
  Upper bound  a full swap to deepseek-v4-flash saves ~98.1% — run with 
               --verbose for detail
  Quality tier gpt-5.5: Elite  →  deepseek-v4-flash: Strong   (LMArena)
  Prices       synced 2026-07-02
  Quality      synced 2026-07-02

⚠ Quality is not verified — 'within tolerance' is an offline estimate;
  run --measure to confirm it on your real outputs before you switch.

  Your data never leaves your machine. Your keys go to your own providers.
→ Route every call automatically and hold the saving:  https://frugon.rodiun.io

Recommendations use a curated set of current top models across providers, drawn
from OpenRouter usage rankings. Prices synced 2026-07-02 from the LiteLLM 
registry. Run `frugon update` for the full live roster.
This is bundled sample data — run `frugon analyze <your-logs>` for a 
recommendation on your own logs.

Your numbers depend on your logs and your locally synced pricing/quality data. Run frugon analyze --demo --candidates claude-sonnet-4-5,gpt-4.1,claude-haiku-4-5,gemini-2.5-flash,deepseek-v4-flash to see the same output on your machine.

Quality tiers for reasoning models reflect the model at its default/typical reasoning effort — effort changes how many tokens a call spends thinking, not its per-token rate, so it never affects the price shown above.

A provider's billing dashboard tells you what you already spent, and a raw token counter prices a single call — Frugon prices your real logs against every model, locally, and tells you which calls to move and which to keep.

Based on RouteLLM's published research (LMSYS):

Traffic mix Typical saving
General mixed workload 30 – 50%
Easy / repetitive (high MT-Bench similarity) up to ~85%
Hard reasoning / MMLU-heavy ~30%

Your actual number comes from your logs. Frugon never inflates — it shows what the math says for your data.

  • Agent builders — your GPT-4o agents are expensive; most easy hops don't need them.
  • AI dev teams — monthly LLM bill is real; routing pays for itself in days.
  • RAG & support — retrieval + rerank is cheap; the final answer call doesn't have to be Opus.
  • Data-ETL pipelines — batch extraction is 100% repeatable; mini models handle it fine.
  • Indie hackers — every dollar saved is a dollar of runway.

This is a one-time snapshot. Want it to keep routing automatically and hold the savings? → frugon.rodiun.io

Star the repo if this saved you money.

Bug reports and pull requests are welcome — see CONTRIBUTING.md. Frugon is deliberately small: six commands (analyze, capture, models, update, pricing, quality), three capabilities (cost analysis, quality visibility, routing recommendation). Gateways, live routing proxies, web UIs, and multi-tenant accounts are out of scope by design.


Built by Rodiun. MIT licensed.

联系我们 contact @ memedata.com