๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ
TakoAPI
์Šคํ‚ฌ๋กœ ๋Œ์•„๊ฐ€๊ธฐ

token-guard

edmonddantesj ์ œ์ž‘

AI & LLMs
โ€”์•„์ง ํ‰๊ฐ€ ์—†์Œ
๋‚ด ํ‰๊ฐ€

์š”์•ฝ

<!-- ๐ŸŒŒ 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 ๋“ฑ ์‚ฌ์šฉํ•˜๋Š” ์ฝ”๋”ฉ ์—์ด์ „ํŠธ์— ๋ถ™์—ฌ๋„ฃ์œผ์„ธ์š”.

๋งํฌ