开源AI工作流:LLM预算控制和AI代理成本治理 是 AI Skill Hub 本期精选Agent工作流之一。综合评分 7.5 分,整体质量较高。我们推荐使用将其纳入你的 AI 工具库,帮助提升工作效率。
shekel是一个开源的AI工作流,提供LLM预算控制和AI代理成本治理功能,帮助开发者更好地管理AI代理的成本和预算。
开源AI工作流:LLM预算控制和AI代理成本治理 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
shekel是一个开源的AI工作流,提供LLM预算控制和AI代理成本治理功能,帮助开发者更好地管理AI代理的成本和预算。
开源AI工作流:LLM预算控制和AI代理成本治理 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
# 方式一:pip 安装(推荐)
pip install shekel
# 方式二:虚拟环境安装(推荐生产环境)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install shekel
# 方式三:从源码安装(获取最新功能)
git clone https://github.com/arieradle/shekel
cd shekel
pip install -e .
# 验证安装
python -c "import shekel; print('安装成功')"
# 命令行使用
shekel --help
# 基本用法
shekel input_file -o output_file
# Python 代码中调用
import shekel
# 示例
result = shekel.process("input")
print(result)
# shekel 配置文件示例(config.yml) app: name: "shekel" debug: false log_level: "INFO" # 运行时指定配置文件 shekel --config config.yml # 或通过环境变量配置 export SHEKEL_API_KEY="your-key" export SHEKEL_OUTPUT_DIR="./output"
pip install shekel[openai] # OpenAI
pip install shekel[anthropic] # Anthropic
pip install shekel[all] # OpenAI + Anthropic + LiteLLM + Gemini + HuggingFace
pip install shekel[cli] # shekel run — enforce budgets without touching code
---
AGENT_BUDGET_USD=5 shekel run agent.py
ENTRYPOINT ["shekel", "run", "agent.py"]
Key flags:
bash --budget 5 # hard stop in USD --warn-at 0.8 # log warning at 80%, hard stop at 100% --max-llm-calls 20 # cap by call count instead of spend --max-tool-calls 50 # cap agent tool calls --warn-only # log but never exit 1 (soft guardrail) --dry-run # track costs, no enforcement --output json # machine-readable spend summary for log pipelines --budget-file shekel.toml # load limits from config file ```
---
```
Works with AsyncRedisBackend for async workflows. Circuit breaker built in — configurable threshold + cooldown. Fail-open or fail-closed.
```
Quota management: backend.set_tenant_limit(...), backend.get_tenant_spend(...), backend.reset_tenant(...), backend.list_tenants(...). Inspect from the command line with shekel tenants list --name api.
Don't want to touch the code at all? Don't.
```bash pip install shekel[cli]
shekel run agent.py --budget 5
budget(
max_usd=5.00, # hard USD cap
warn_at=0.8, # warn at 80%
max_llm_calls=50, # cap by call count
max_tool_calls=100, # cap tool dispatches
tool_prices={"web_search": 0.01}, # charge per tool
fallback={"at_pct": 0.8, "model": "gpt-4o-mini"}, # switch instead of crash
name="my-agent", # required for nesting + temporal budgets
backend=RedisBackend(), # distributed enforcement across processes
)
budget("$5/hr + 100 calls/hr", name="api-tier") # multi-cap rolling-window
Component caps — all chainable, all raise before the component executes:
b.node("fetch_data", max_usd=0.50) # LangGraph node → NodeBudgetExceededError
b.chain("retriever", max_usd=0.20) # LangChain chain → ChainBudgetExceededError
b.agent("researcher", max_usd=1.00) # CrewAI agent → AgentBudgetExceededError
b.task("summarize", max_usd=0.50) # CrewAI task → TaskBudgetExceededError
Exceptions — all subclass BudgetExceededError, so one except catches everything:
| Exception | Raised when | Key fields |
|---|---|---|
BudgetExceededError | Global cap hit | spent, limit, model, retry_after |
NodeBudgetExceededError | LangGraph node cap hit | node_name, spent, limit |
AgentBudgetExceededError | CrewAI / OAI Agents agent cap hit | agent_name, spent, limit |
TaskBudgetExceededError | CrewAI task cap hit | task_name, spent, limit |
ChainBudgetExceededError | LangChain chain cap hit | chain_name, spent, limit |
ToolBudgetExceededError | Tool call cap hit | tool_name, calls_used, calls_limit |
AgentLoopError | Tool called too many times in window | tool_name, call_count, window_seconds |
SpendVelocityExceededError | Burn rate exceeds max_velocity | velocity_per_min, limit_per_min |
BudgetConfigMismatchError | Redis name reused with different limits | — |
---
Built-in pricing for GPT-4o, GPT-4o-mini, o1, o3, Claude 3.5/3/3.7 Sonnet, Claude 3 Haiku/Opus, Gemini 2.0/2.5 Flash/Pro, and more.
pip install shekel[all-models] # 400+ models via tokencost
shekel models # list all bundled models and pricing
shekel estimate --model gpt-4o --input-tokens 1000 --output-tokens 500
---
shekel是一个开源的AI工作流,提供LLM预算控制和AI代理成本治理功能,帮助开发者更好地管理AI代理的成本和预算。虽然shekel提供了很多有用的功能,但仍然需要进一步的开发和测试来确保其稳定性和可靠性。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
经综合评估,开源AI工作流:LLM预算控制和AI代理成本治理 在Agent工作流赛道中表现稳健,质量良好。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | shekel |
| 原始描述 | 开源AI工作流:LLM budget control and cost governance for AI agents. Python library for token b。⭐16 · Python |
| Topics | workflowagentic-aiagentsai-cost-controlai-governanceai-guardrails |
| GitHub | https://github.com/arieradle/shekel |
| License | MIT |
| 语言 | Python |
收录时间:2026-06-04 · 更新时间:2026-06-04 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端