SuperAPIAI Directory

modelcostsaver

github.com · AI developer platforms

Offline LLM cost prediction: estimate request costs, pick the cheapest capable model, compare models, list prices and optimize requests.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsAPI

About this tool

Purpose: ModelCostSaver is a Model Context Protocol (MCP) server that provides free, zero-configuration tools for AI coding agents or IDEs, answering three questions before making an LLM call: what does the prompt cost across candidate models (predict_cost, estimate_cost); which model is cheapest while satisfying the task (select_optimal_model); and how do the options compare side by side (compare_models). It performs pure pricing and routing math based on a bundled, dated price catalog; the core requires no API key and makes no network requests.

Main capabilities: seven tools in total. Every cost-related result carries catalogVersion and asOf so you can check price freshness; every selection includes a reasoning array rather than being a black-box choice. The recommendation scope is filtered along two axes: the availability axis by the set of allowed providers (by default from the connected client, overridable in order by the per-call providers parameter, the MODELCOSTSAVER_PROVIDERS environment variable, configuration, client defaults, and all); the target axis splits into target: 'self' (default, the current client's next inference) and target: 'code' (calling from your own application, with you supplying that provider's key, in which case client scope does not apply and all providers in the catalog are selectable). If the globally cheapest model is not in the actionable set, it is flagged with cheaperIfAvailable and a reason, and never silently selected.

Usage: run it directly with npx, no installation or key required: npx @workswarm/modelcostsaver. You can write configuration for your editor in one command, such as npx -y @workswarm/modelcostsaver install --client cursor, or manually add the mcpServers block to ~/.cursor/mcp.json, .mcp.json, claude_desktop_config.json, .vscode/mcp.json, ~/.codeium/windsurf/mcp_config.json, etc. When installing for Claude clients, MODELCOSTSAVER_PROVIDERS=anthropic is preset as a sensible default for target: self, overridable per call or via environment variable. After adding it, restart the client and confirm that the seven tools appear in the tool list.

Prediction method: token counts are exact when provided, otherwise estimated with a heuristic (about 4 characters/token, adjustable via MODELCOSTSAVER_CHARS_PER_TOKEN); output tokens come from an explicit value, a task-class cap, a model cap, or a conservative default. The cost formula is (inTok / 1e6) * inputPerMillion + (outTok / 1e6) * outputPerMillion, expressed in full-precision dollars and integer usdMicros; predictions are never rounded to cents. When selecting, it resolves the target tier (an explicit taskClass or a transparent keyword/length classifier), filters candidates by tier, capability, and provider scope, predicts each candidate, places over-budget ones in rejected, picks the cheapest, records each step in reasoning, and returns a fallbackChain for retries on failure.

Limitations and trust: the core is offline and only reads the bundled catalog; only when MODELCOSTSAVER_REFRESH=on does it make a single GET of a static JSON, validated with zod and cached with a TTL, and any failure falls back to the bundled catalog. No telemetry; record_usage writes to a JSONL file under your own configuration directory only when MODELCOSTSAVER_LEDGER=on. Only two dependencies (@modelcontextprotocol/sdk and zod), Apache-2.0 licensed, published as @workswarm/modelcostsaver. stdout carries only JSON-RPC, logs go to stderr. Prices change frequently, and the bundled catalog carries a version and date; verify against provider invoices before using for billing. Configuration precedence: tool call parameters > environment variables > modelcostsaver.config.json (current directory, then user configuration directory) > built-in defaults.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools