AI Skill Hub 推荐使用:开源AI工作流 是一款优质的Agent工作流。AI 综合评分 7.5 分,在同类工具中表现稳健。如果你正在寻找可靠的Agent工作流解决方案,这是一个值得深入了解的选择。
Like a spell checker, but for your AI costs。扫描代码,估算成本,阻止超支。
开源AI工作流 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
Like a spell checker, but for your AI costs。扫描代码,估算成本,阻止超支。
开源AI工作流 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
# 方式一:npm 全局安装 npm install -g inferwise # 方式二:npx 直接运行(无需安装) npx inferwise --help # 方式三:项目依赖安装 npm install inferwise # 方式四:从源码运行 git clone https://github.com/inferwise/inferwise cd inferwise npm install npm start
# 命令行使用
inferwise --help
# 基本用法
inferwise [options] <input>
# Node.js 代码中使用
const inferwise = require('inferwise');
const result = await inferwise.run(options);
console.log(result);
# inferwise 配置说明 # 查看配置选项 inferwise --config-example > config.yml # 常见配置项 # output_dir: ./output # log_level: info # workers: 4 # 环境变量(覆盖配置文件) export INFERWISE_CONFIG="/path/to/config.yml"
<p align="center"> <img src="assets/banner.png" alt="Inferwise" width="120" /> </p>
An AI coding agent builds a RAG pipeline and picks Opus for every step — embeddings, retrieval, summarization, response generation. Those calls will run in production, billed per token to your API key.
Without Inferwise: The agent picks the most capable (and expensive) model for every call. The bill shows up after the code ships. $2,400/mo.
With Inferwise MCP: The agent calls suggest_model for each task — it learns that classification only needs gpt-4o-mini, summarization works fine on claude-sonnet-4, and only the reasoning step needs claude-opus-4. Cost drops to $600/mo before a single line ships.
With Inferwise CI: Even if the agent doesn't use MCP, inferwise diff flags "+$2,400/mo in new API costs" on the PR. The developer swaps models. Same result.
$1,800/mo saved before a single line ships.
---
```bash
Your code:
anthropic.messages.create({
model: "claude-opus-4-20250514",
system: "Classify tickets into: billing, technical, account",
messages: [{ role: "user", content: ticket }],
})
Inferwise analyzes:
System prompt extracted -> medium confidence
No code/reasoning keywords -> capability: [general]
Opus 4 = premium tier, quality: 94/100, $75/M output
Candidates passing quality gate (general, quality >= 66):
o3 mid tier, quality: 94, $8/M -> quality-adj: $8.51/M
gpt-4.1 mid tier, quality: 90, $8/M -> quality-adj: $8.89/M
gpt-4o mid tier, quality: 77, $10/M -> quality-adj: $12.99/M
Blocked by quality gate:
flash-lite budget, quality: 52 -> 52/94 = 55% < 70% threshold
Result:
chat-service.ts:8 claude-opus-4 -> o3 (openai)
Use case: [general] (medium confidence)
Savings: $527/mo -- quality: 94 vs 94
Every model in the pricing database is tagged with its capabilities and quality benchmarks. See packages/pricing-db/providers/ for pricing and packages/pricing-db/benchmarks.json for quality scores.
---
npx inferwise init
Create with inferwise init or manually:
{
"defaultVolume": 1000,
"ignore": ["node_modules", "dist", "build", "test", "__tests__", "*.test.ts", "*.spec.ts"],
"overrides": [
{
"pattern": "src/chat/**",
"volume": 5000
}
],
"budgets": {
"warn": 2000,
"block": 50000,
"requireApproval": 10000,
"approvers": ["platform-eng", "@infra-team"]
},
"telemetry": {
"backend": "grafana-tempo",
"endpoint": "https://tempo.internal:3200",
"apiKey": "glsa_..."
}
}
Budget thresholds (monthly cost increase in USD):
| Field | Default | Description |
|---|---|---|
warn | $2,000 | Warning in stderr (CLI) or yellow label on PR (GitHub Action) |
block | $50,000 | **Hard gate.** Exit code 1 (CLI) or red label + failed check (GitHub Action). Blocks merge in any CI. |
requireApproval | — | **Soft gate, GitHub Action only.** Orange label + requests review from approvers. Does not fail CI — relies on branch protection rules to enforce. |
approvers | — | GitHub teams or users who can approve over-budget PRs. Only used with requireApproval. |
Budget defaults are deliberately high — block is an emergency brake for catastrophic changes (wrong model at scale, missing max_tokens cap), not routine cost increases.
| Variable | Description |
|---|---|
INFERWISE_CONFIG | Path to config file (overrides auto-discovery) |
INFERWISE_VOLUME | Default daily request volume (overridden by --volume) |
ANTHROPIC_ADMIN_API_KEY | Calibration via Anthropic Admin API |
OPENAI_API_KEY | Calibration via OpenAI Usage API |
OPENROUTER_API_KEY | Calibration via OpenRouter (all providers in one call) |
---
ANTHROPIC_ADMIN_API_KEY=sk-ant-admin-... inferwise calibrate .
OPENROUTER_API_KEY=sk-or-... inferwise calibrate .
Fetches real usage data from provider APIs (or OpenRouter), computes correction ratios, and stores them locally. Future estimates go from "2-5x accuracy" to "within 20%".
**6. Connect to OTel for production-accurate estimates (optional)**
Add to `inferwise.config.json`:
json { "telemetry": { "backend": "grafana-tempo", "endpoint": "https://tempo.internal:3200", "apiKey": "glsa_..." } } ```
If your LLM calls are instrumented with OpenTelemetry (using the GenAI semantic conventions), Inferwise reads your existing traces to get real token averages per model. Estimates go from "2-5x accuracy" to "within 10%". Supports Grafana Tempo and Prometheus/OTLP backends.
---
| Package | Who Uses It | What It Does |
|---|---|---|
[inferwise](https://www.npmjs.com/package/inferwise) | Developers, CI, AI agents | CLI + SDK — scan, estimate, diff, check, audit, enforce budgets |
[@inferwise/pricing-db](packages/pricing-db) | Model routers, cost-aware apps | Bundled pricing for 35+ models across 5 providers, capability-based model selection, updated daily |
[@inferwise/mcp](packages/mcp-server) | AI agents (Claude Code, Cursor, VS Code, Windsurf) | MCP server — suggest models, estimate costs, audit codebases as AI agent tools |
[inferwise/inferwise-action](packages/github-action) | GitHub repos | PR cost comments, labels, reviewer requests, merge blocking |
---
Every AI API call in your codebase can pass through four tiers before it reaches production.
Code written (by human or AI agent)
|
v
+-----------+
| TIER 0 | Smart model selection (before/during code writing)
| | MCP suggest_model / inferwise audit
| | "Use gpt-4o-mini — classification doesn't need Opus"
+-----+-----+
|
v
+-----------+
| TIER 1 | Pre-commit hook (developer machine)
| | inferwise estimate .
| | "This commit adds $2,400/mo in LLM costs"
+-----+-----+
| developer pushes
v
+-----------+
| TIER 2 | CI gate (GitHub Action / GitLab / any CI)
| | inferwise diff --base main --head HEAD
| | Posts cost report on PR, applies labels
+-----+-----+
| budget check
v
+-----------+
| TIER 3 | Budget policy (inferwise.config.json)
| | warn: $2,000 -> yellow label, warning in PR
| | block: $50,000 -> exit code 1, fails CI, blocks merge
+-----------+
| Tier | Where | What Happens |
|---|---|---|
| Smart selection | MCP server / inferwise audit | Recommends cheapest capable model for each task |
| Pre-commit hook | Developer machine | Shows costs before commit, catches obvious spikes |
| CI required check | PR/MR merge gate | Blocks merge if budget exceeded, comments cost report |
| Budget policy | inferwise.config.json | Org-wide thresholds committed to the repo, code-reviewed like any other config |
1. Setup (once)
npx inferwise init
Creates inferwise.config.json, installs a pre-commit hook, prints CI setup instructions for GitHub Actions / GitLab / Bitbucket / Jenkins.
2. Audit existing code for optimization
npx inferwise audit .
SMART MODEL ALTERNATIVES
src/rag.ts:6 — claude-opus-4 → claude-sonnet-4 (anthropic)
Use case: general (high confidence)
Reason: Task requires [general] — Sonnet handles that at 79% savings
Savings: $14,595/mo ($18,440 → $3,845)
src/classify.ts:14 — gpt-4o → gpt-4o-mini (openai)
Use case: general (medium confidence)
Reason: Task requires [general] — gpt-4o-mini handles that at 90% savings
Savings: $4,500/mo ($5,000 → $500)
Inferwise reads the prompts in your code, infers what each LLM call does, and recommends cheaper models that can handle the task. See How Model Selection Works for details.
3. Write code with LLM API calls
You (or an AI coding agent) write code that calls provider APIs. On git commit, the pre-commit hook runs automatically:
$ git commit -m "feat: add summarizer"
File Line Provider Model Cost/Call Monthly
src/summarize.ts 18 openai gpt-4o $0.0064 $192/mo
src/rag.ts 91 anthropic claude-opus-4 $0.0429 $1,287/mo
Total: $1,479/mo (at 1,000 req/day)
You see the cost impact before the code leaves your machine.
4. Open a pull request
CI runs inferwise diff. The GitHub Action posts a cost report directly on the PR:
| File | Model | Change | Monthly Impact |
|---|---|---|---|
| src/summarize.ts | (new) gpt-4o | Added | +$192/mo |
| src/rag.ts | claude-sonnet-4 -> claude-opus-4 | Upgrade | +$1,050/mo |
Net: +$1,242/mo
If the increase exceeds budgets.block, the PR is blocked from merging.
5. Calibrate for tighter estimates (optional)
```bash
pipelines:
pull-requests:
'**':
- step:
name: Cost Check
script:
- npx inferwise diff --format table
npx inferwise diff
For AI agents — add the MCP server:
bash
{ "mcpServers": { "inferwise": { "command": "npx", "args": ["-y", "@inferwise/mcp"] } } }
Or install globally:
bash npm install -g inferwise
{ "mcpServers": { "inferwise": { "command": "npx", "args": ["-y", "@inferwise/mcp"] } } }
Once connected, the agent gets four tools:
| Tool | What It Does |
|------|-------------|
| `suggest_model` | Describe a task, get back the cheapest capable model with alternatives and reasoning |
| `estimate_cost` | Estimate the cost of an LLM API call given provider, model, and token counts |
| `audit` | Scan a directory for LLM API calls and suggest cheaper capable alternatives |
| `apply_recommendations` | Auto-apply model swap recommendations to source files (from audit or explicit list) |
**Example flow — new code:** An agent writing a classification pipeline calls `suggest_model` with task "classify support tickets by category" — Inferwise returns `gpt-4o-mini` at $0.60/MTok instead of `gpt-4o` at $10/MTok. The agent writes the code with the right model from the start.
**Example flow — existing code:** An agent calls `apply_recommendations` with `{ directory: "." }` — Inferwise audits the codebase, finds that `claude-opus-4` is overkill for a classification task, and rewrites the model ID to `claude-sonnet-4` in the source file. The agent commits the change. No human needed.
The MCP server runs locally as a subprocess — no hosted infrastructure, no API keys needed. It communicates via stdio using JSON-RPC. Works with Claude Code, Cursor, VS Code (1.99+), Windsurf, Cline, and any MCP-compatible tool.
#### Programmatic Alternatives
For agents and pipelines that don't support MCP:
**SDK** — embed directly in agent pipelines:
typescript import { estimateAndCheck } from "inferwise/sdk";
const result = await estimateAndCheck("./src", { maxMonthlyCost: 10000, volume: 5000 }); if (!result.ok) console.error("Over budget:", result.violations);
**CLI** — tool-use for agents and scripts:
bash inferwise check . --max-monthly-cost 10000 --format json inferwise price openai gpt-4o --input-tokens 2000 --output-tokens 1000 --format json
**Pricing database** — for model routers and cost-aware selection:
typescript import { suggestModelForTask, calculateCost, getModel } from "@inferwise/pricing-db";
const suggestion = suggestModelForTask("classify support tickets"); const cost = calculateCost({ model: suggestion.model, inputTokens: 2000, outputTokens: 500 }); ```
---
此项目提供了一个开源的AI工作流,用于成本优化和成本控制。虽然它有潜在的风险,但也提供了一个有用的工具。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ Apache 2.0 — 宽松开源协议,可商用,需保留版权声明和 NOTICE 文件,含专利授权条款。
总体来看,开源AI工作流 是一款质量良好的Agent工作流,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。
| 原始名称 | inferwise |
| 原始描述 | 开源AI工作流:Like a spell checker, but for your AI costs. Scans code, estimates spend, blocks。⭐7 · TypeScript |
| Topics | workflowaiclicost-optimizationdevtoolsfinopstypescript |
| GitHub | https://github.com/inferwise/inferwise |
| License | Apache-2.0 |
| 语言 | TypeScript |
收录时间:2026-05-23 · 更新时间:2026-05-23 · License:Apache-2.0 · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端