File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # API-Token-
2- 一个简单的多线程命令行工具,用于测试你的 API token上限,统计账户余额能消耗多少 token。
1+ # 🔥 API Token 消耗测试工具
2+
3+ 一个简单的多线程命令行工具,用于测试你的 API 余额上限,统计账户余额能消耗多少 token。
4+
5+ ## ✨ 功能特点
6+
7+ - 🖥️ ** 交互式配置** — 启动时依次填入 URL、API Key、模型、线程数、token 数
8+ - ⚡ ** 多线程并发** — 同时发送多个请求,最大化消耗速度
9+ - 📊 ** 实时统计** — 每个线程独立输出,实时显示累计 token 数
10+ - 🛑 ** 自动停止** — 检测到 402 余额不足时自动退出并打印汇总
11+ - ⏹️ ** 随时中断** — Ctrl+C 手动停止,自动打印最终统计
12+
13+ ## 📦 安装依赖
14+
15+ ``` bash
16+ pip install anthropic
17+ ```
18+
19+ ## 🚀 使用方法
20+
21+ ``` bash
22+ python burn_tokens.py
23+ ```
24+
25+ 按提示依次填入配置:
26+
27+ ```
28+ Base URL [https://api.anthropic.com]: http://你的代理地址/
29+ API Key : sk-ant-xxxx
30+ Model [claude-haiku-4-5-20251001]: 你的模型名
31+ 并发线程数 [5]: 5
32+ 每个请求 output tokens [2000]: 2000
33+ ```
34+
35+ > 直接回车则使用括号内的默认值。
36+
37+ ## 📈 输出示例
38+
39+ ```
40+ --- Batch #1 (5 concurrent) ---
41+ [T01] ✓ in=120 out=2,000 | cumulative=2,120
42+ [T02] ✓ in=120 out=1,984 | cumulative=6,224
43+ [T03] ✓ in=120 out=2,000 | cumulative=10,344
44+ ...
45+
46+ ============================================================
47+ Batches : 12
48+ Requests : 60
49+ Errors : 0
50+ Input tok : 7,200
51+ Output tok : 118,500
52+ Total tok : 125,700
53+ ============================================================
54+ ```
55+
56+ ## ⚙️ 配置参数说明
57+
58+ | 参数 | 说明 | 默认值 |
59+ | ------| ------| --------|
60+ | Base URL | API 接入地址 | ` https://api.anthropic.com ` |
61+ | API Key | 你的 API 密钥 | — |
62+ | Model | 模型名称 | ` claude-haiku-4-5-20251001 ` |
63+ | 并发线程数 | 同时发送的请求数量 | ` 5 ` |
64+ | 每次 output tokens | 每个请求最大输出 token 数 | ` 2000 ` |
65+
66+ ## 📝 开源协议
67+
68+ MIT
You can’t perform that action at this time.
0 commit comments