跳到正文
TakoAPI
返回技能列表

tokenguard

由 g0head 提供

AI & LLMs
1.6k下载量由 clawskills.sh 提供
3星标
0浏览量
0 个赞登录后即可为这个技能点赞
—暂无评分
你的评分

简介

API cost guardian for AI agents.

描述

该技能的功能

TokenGuard tracks API spending per session, enforces configurable dollar limits, and blocks actions when budgets are exceeded. It logs every cost with timestamps and provides pre-flight budget checks before expensive calls.

Unlike ad-hoc manual tracking, TokenGuard enforces limits programmatically via exit codes, so scripts and agents can gate expensive operations without any custom logic.

何时使用

  • Stopping a runaway agent loop before it burns $200 overnight
  • Setting a $10 daily cap during development of a new AI feature
  • Auditing which operations consumed the most API budget last week
  • Scripting a CI pipeline that skips expensive calls when over budget
  • Extending a session limit mid-task without losing the spending history

示例工作流

输入

User asks: check if I can afford a $5 API call, then log the actual cost

智能体
  1. 1

    Run tokenguard status to see current limit and remaining balance

  2. 2

    Run tokenguard check 5.00 to verify the estimated cost fits the budget

  3. 3

    Call the external API if exit code is 0

  4. 4

    Run tokenguard log 4.23 "Claude Sonnet - summarization" to record the actual cost

  5. 5

    Run tokenguard history to confirm the entry was saved

输出

Spending log updated: $4.23 recorded, remaining balance displayed

安装

clawhub install g0head/tokenguard

运行 CLI 命令,或把这段提示词粘贴到 Claude Code、Cursor、Codex 或你在用的任意编程智能体里。

链接