LLM请求监控工具:中间人代理调试方案
开源MitM代理工具让开发者拦截和观察LLM工具的请求,便于诊断问题和优化性能。
开源MitM代理工具让开发者拦截和观察LLM工具的请求,便于诊断问题和优化性能。
Installation • Quick Start • Features • Commands • Contributing
tokentap 使用实时终端仪表板来追踪 LLM CLI 工具的代币使用情况。实时查看你正在使用多少代币。
追踪代币使用:准确看到每个请求消耗多少代币
监控上下文窗口:视觉化油表显示累积用量相对于限额的情况
调试提示词:自动将每个提示词保存为 markdown 和 JSON 格式供审查
零配置:无需证书,无需设置 - 安装即用
pip install tokentap
或从源代码安装:
git clone https://github.com/jmuncor/tokentap.git
cd tokentap
pip install -e .
tokentap start
系统会提示你选择保存捕获提示词的位置,然后仪表板出现:
┌─────────────────────────────────────────────────────────────┐
│ TOKENTAP - LLM Traffic Inspector │
├─────────────────────────────────────────────────────────────┤
│ Context Usage ████████████░░░░░░░░░░░░░░░░ 42% │
│ (84,231 / 200,000 tokens) │
├─────────────────────────────────────────────────────────────┤
│ Time Provider Model Tokens │
│ 14:23:01 Anthropic claude-sonnet-4-20250514 12,847 │
│ 14:23:45 Anthropic claude-sonnet-4-20250514 8,234 │
│ 14:24:12 Anthropic claude-sonnet-4-20250514 15,102 │
├─────────────────────────────────────────────────────────────┤
│ Last Prompt: "Can you help me refactor this function..." │
└─────────────────────────────────────────────────────────────┘
# For Claude Code
tokentap claude
# For Gemini CLI (see known issues)
tokentap gemini
# For OpenAI Codex
tokentap codex
# For MiniMax-powered tools
tokentap run --provider minimax python my_app.py
就这么简单!在工作时观看仪表板的实时更新。
实时代币追踪,带有彩色编码的油表:
每个拦截的请求都保存到你选择的目录:
退出时,查看你的总用量:
Session complete. Total: 84,231 tokens across 12 requests.
--provider 支持的供应商:anthropic, openai, gemini, minimax
tokentap start [OPTIONS]
Options:
-p, --port NUM Proxy port (default: 8080)
-l, --limit NUM Token limit for fuel gauge (default: 200000)
tokentap claude [OPTIONS] [ARGS]...
Options:
-p, --port NUM Proxy port (default: 8080)
┌─────────────────────────────────────────────────────────────────┐
│ Terminal 1: tokentap start │
│ ┌─────────────────────────────────────────────────────────────┐│
│ │ HTTP Proxy (localhost:8080) ││
│ │ + Dashboard ││
│ │ + Prompt Archive ││
│ └─────────────────────────────────────────────────────────────┘│
└───────────────────────────────┬─────────────────────────────────┘
│ HTTP
│
┌───────────────────────────────┴─────────────────────────────────┐
│ Terminal 2: tokentap claude │
│ ┌─────────────────────────────────────────────────────────────┐│
│ │ Sets ANTHROPIC_BASE_URL=http://localhost:8080 ││
│ │ Runs: claude ││
│ └─────────────────────────────────────────────────────────────┘│
└─────────────────────────────────────────────────────────────────┘
│
│ HTTPS
▼
┌───────────────────┐
│ api.anthropic.com │
└───────────────────┘
对于像 MiniMax 这样的 OpenAI 兼容供应商,tokentap 使用路径前缀路由,以便请求转发到正确的上游 API:
tokentap run --provider minimax python my_app.py
→ sets OPENAI_BASE_URL=http://localhost:8080/minimax/v1
→ requests arrive at /minimax/v1/chat/completions
→ proxy strips prefix, forwards to https://api.minimax.io/v1/chat/completions
Gemini CLI 目前有一个已知问题,当使用 OAuth 认证时会忽略自定义基础 URL。一旦 Gemini CLI 团队修复此问题,tokentap 的 Gemini 支持将自动生效。
欢迎贡献!以下是你可以帮助的方式:
创建一个特性分支(git checkout -b feature/amazing-feature)
提交你的更改(git commit -m 'Add amazing feature')
推送到分支(git push origin feature/amazing-feature)
git clone https://github.com/jmuncor/tokentap.git
cd tokentap
python -m venv venv
source venv/bin/activate
pip install -e .
本项目基于 MIT 许可证发布 - 详见 LICENSE 文件。
查看真正发送给 LLM 的内容。追踪。学习。优化。