Token Tracker
Author: zruler
Blog: https://www.zruler.fun/
Email: zruler@163.com
Feedback: 有问题请及时反馈!Issues and suggestions welcome.
Report token usage and estimated cost for the current conversation.
When to Trigger
- 1. User asks — "token用了多少"、"花了多少钱"、"cost"、"usage" 等
- Long conversation ends — 复杂任务完成后主动报告
- User requests summary — 明确要求看用量统计
Quick Usage
Call session_status to get current session metrics, then format a user-friendly summary.
Response Format
After getting session_status, report in this format:
CODEBLOCK0
Model Pricing Reference (USD per 1M tokens)
| Model | Input | Output | Cached Input |
|---|
| claude-sonnet-4-20250514 | $3 | $15 | $0.30 |
| claude-opus-4-20250514 |
$15 | $75 | $1.50 |
| gpt-4o | $2.50 | $10 | $1.25 |
| gpt-4o-mini | $0.15 | $0.60 | $0.075 |
| o1 | $15 | $60 | $7.50 |
| o3-mini | $1.10 | $4.40 | $0.55 |
| gemini-2.0-flash | $0.10 | $0.40 | $0.025 |
| gemini-2.5-pro | $1.25-$2.50 | $10-$15 | - |
| deepseek-chat | $0.27 | $1.10 | $0.07 |
| deepseek-reasoner | $0.55 | $2.19 | $0.14 |
Note: Actual cost from session_status is authoritative. This table is for reference only.
Usage Tips
- - For long conversations, suggest compaction if context > 80%
- Note cache hit rate — high cache = lower actual cost
- If user asks for historical usage, explain this tracks current session only
Token Tracker
作者: zruler
博客: https://www.zruler.fun/
邮箱: zruler@163.com
反馈: 有问题请及时反馈!欢迎提出问题和建议。
报告当前对话的Token使用量和预估费用。
触发时机
- 1. 用户主动询问 — 如token用了多少、花了多少钱、cost、usage等
- 长对话结束 — 复杂任务完成后主动报告
- 用户请求总结 — 明确要求查看用量统计
快速使用
调用session_status获取当前会话指标,然后格式化为用户友好的摘要。
回复格式
获取session_status后,按以下格式报告:
📊 本次对话用量
🧮 Tokens: {输入} 入 / {输出} 出
💵 费用: ${费用}
🗄️ 缓存: {缓存命中率}% 命中 ({缓存量} 缓存 / {新增量} 新)
📚 上下文: {已用}/{上限} ({百分比}%)
模型定价参考(每100万Token,美元)
| 模型 | 输入 | 输出 | 缓存输入 |
|---|
| claude-sonnet-4-20250514 | $3 | $15 | $0.30 |
| claude-opus-4-20250514 |
$15 | $75 | $1.50 |
| gpt-4o | $2.50 | $10 | $1.25 |
| gpt-4o-mini | $0.15 | $0.60 | $0.075 |
| o1 | $15 | $60 | $7.50 |
| o3-mini | $1.10 | $4.40 | $0.55 |
| gemini-2.0-flash | $0.10 | $0.40 | $0.025 |
| gemini-2.5-pro | $1.25-$2.50 | $10-$15 | - |
| deepseek-chat | $0.27 | $1.10 | $0.07 |
| deepseek-reasoner | $0.55 | $2.19 | $0.14 |
注意:session_status返回的实际费用具有权威性。此表格仅供参考。
使用技巧
- - 对于长对话,建议在上下文使用率超过80%时进行压缩
- 关注缓存命中率 — 高缓存意味着实际费用更低
- 如果用户询问历史用量,请说明此功能仅追踪当前会话