Skip to content

WENGENG-boop/API-Token-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

🔥 API Token 消耗测试工具

一个简单的多线程命令行工具,用于测试你的 API 余额上限,统计账户余额能消耗多少 token。

✨ 功能特点

  • 🖥️ 交互式配置 — 启动时依次填入 URL、API Key、模型、线程数、token 数
  • 多线程并发 — 同时发送多个请求,最大化消耗速度
  • 📊 实时统计 — 每个线程独立输出,实时显示累计 token 数
  • 🛑 自动停止 — 检测到 402 余额不足时自动退出并打印汇总
  • ⏹️ 随时中断 — Ctrl+C 手动停止,自动打印最终统计

📦 安装依赖

pip install anthropic

🚀 使用方法

python burn_tokens.py

按提示依次填入配置:

Base URL   [https://api.anthropic.com]: http://你的代理地址/
API Key   : sk-ant-xxxx
Model      [claude-haiku-4-5-20251001]: 你的模型名
并发线程数   [5]: 5
每个请求 output tokens [2000]: 2000

直接回车则使用括号内的默认值。

📈 输出示例

--- Batch #1 (5 concurrent) ---
  [T01] ✓  in=120  out=2,000  | cumulative=2,120
  [T02] ✓  in=120  out=1,984  | cumulative=6,224
  [T03] ✓  in=120  out=2,000  | cumulative=10,344
  ...

============================================================
  Batches    : 12
  Requests   : 60
  Errors     : 0
  Input tok  : 7,200
  Output tok : 118,500
  Total tok  : 125,700
============================================================

⚙️ 配置参数说明

参数 说明 默认值
Base URL API 接入地址 https://api.anthropic.com
API Key 你的 API 密钥
Model 模型名称 claude-haiku-4-5-20251001
并发线程数 同时发送的请求数量 5
每次 output tokens 每个请求最大输出 token 数 2000

📝 开源协议

MIT

About

一个简单的多线程命令行工具,用于测试你的 API token上限,统计账户余额能消耗多少 token。

Resources

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages