跳到正文
TakoAPI
返回技能列表

token-guard

由 edmonddantesj 提供

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

简介

<!-- 🌌 Aoineco-Verified | S-DNA: AOI-2026-0213-SDNA-TG01 -->.

描述

该技能的功能

Intercepts LLM API requests before they're sent to prevent 429 rate limit errors. Tracks per-model token usage with a sliding window and automatically waits, falls back to another model, or blocks runaway duplicate requests. Works with Gemini, Claude, GPT-4o, and DeepSeek with pre-configured quotas.

Unlike post-hoc retry wrappers, it estimates token count before the call so failed requests never consume quota.

何时使用

  • Processing large PDFs without hitting Gemini's 1M TPM limit
  • Detecting and stopping retry loops that spiral into quota exhaustion
  • Switching to a cheaper model automatically when primary quota runs low
  • Caching repeated prompts to avoid redundant API calls
  • Monitoring token spend across multiple models in a single agent run

示例工作流

输入

User asks: process this 200-page PDF using Gemini Flash

智能体
  1. 1

    Call guard.check(prompt_text, model='gemini-3-flash') to estimate token count

  2. 2

    Receive decision.action == 'wait' because usage is above 80% of 1M TPM limit

  3. 3

    Sleep for decision.wait_seconds, then re-check

  4. 4

    Receive decision.action == 'proceed', call the LLM API

  5. 5

    Call guard.record_usage() and guard.cache_response() to update quota tracking

输出

PDF processed without a 429 error; quota state updated for subsequent calls

安装

clawhub install edmonddantesj/token-guard

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

链接