Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Combines model routing by task complexity, budget tracking, retry logic and prompt caching to control LLM API costs.
61% 91%+30 ptsof test cases passed
Passed 21 of 23 test cases with the skill, and 14 of 23 without it.
3 of 3 safety checks passed
Not used yet
在保持质量的同时控制 LLM API 成本的模式。将模型路由 (Model Routing)、预算跟踪 (Budget Tracking)、重试逻辑 (Retry Logic) 和提示词缓存 (Prompt Caching) 组合成一个可复用的流水线。
为简单任务自动选择更便宜的模型,将昂贵的模型留给复杂任务。
MODEL_SONNET = "claude-sonnet-4-6"
MODEL_HAIKU = "claude-haiku-4-5-20251001"
_SONNET_TEXT_THRESHOLD = 10_000 # 字符数阈值
_SONNET_ITEM_THRESHOLD = 30 # 项目数阈值
def select_model(
text_length: int,
item_count: int,
force_model: str | None = None,
) -> str:
"""根据任务复杂度选择模型。"""
if force_model is not None:
return force_model
if text_length >= _SONNET_TEXT_THRESHOLD or item_count >= _SONNET_ITEM_THRESHOLD:
return MODEL_SONNET # 复杂任务
return MODEL_HAIKU # 简单任务 (便宜 3-4 倍)
使用冻结的数据类 (Frozen Dataclasses) 跟踪累计支出。每次 API 调用都会返回一个新的跟踪器——绝不修改原始状态。
Published skills whose descriptions closely match this one, with their benchmark result.
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.