You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenAI Chat Completions API:为何prompt_tokens消耗超出预期?

GPT-3.5-Turbo Token计数疑问解答

该计数是正确的,原因在于GPT-3.5-Turbo的token计数并非仅统计你输入的content字段内容,而是包含了对话格式所需的额外结构标记与角色标识:

  • 当发送{"role":"user","content":"What is the most beautiful country?"}时,API会将消息转换为内部格式:

    <|im_start|>user
    What is the most beautiful country?<|im_end|>
    

    其中<|im_start|>、user、<|im_end|>及换行符都会被计入token。你原本计算的7个token仅对应content里的文本,加上这些额外元素后,总token数达到15,与实际结果一致。

  • 当仅发送{"role":"user","content":"."}时,内部格式为:

    <|im_start|>user
    .<|im_end|>
    

    其中<|im_start|>(2个token)、user(1个token)、换行符(1个token)、.(1个token)、<|im_end|>(2个token),再加上对话上下文的基础结构开销,最终总token数为9,符合你遇到的情况。

GPT-3.5-Turbo这类对话模型会为每个消息添加标准化的分隔标记与角色头,这些都会占用token配额,因此实际计数会比单独统计content文本的token数多。

内容的提问来源于stack exchange,提问作者Alberto Pereda Rojas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 03:27:54