本地计数
本地计数
n = len(tok.encode("你的完整提示词"))
print(n) # 与该提示在服务端实际计费的 token 数对照服务端接口(vLLM)
服务端接口(vLLM)
curl -s http://127.0.0.1:8000/tokenize -H 'Content-Type: application/json' \
-d '{"model": "<模型名>", "prompt": "你好"}'聊天模板、系统提示与工具描述都会占 token:预算要按渲染后的完整输入计算。