chatgpt4o api流式输出如何计算消耗的tokens数量?
如何不是流式输出会输出总的消耗token数量,那么流式模式下呢?
这是非流式模式下输出tokens数量:
{ "id": "chatcmpl-123", "object": "chat.completion", "created": 1677652288, "choices": [{ "index": 0, "message": { "role": "assistant", "content": "\n\nHello there, how may I assist you today?", }, "finish_reason": "stop" }], "usage": { "prompt_tokens": 9, "completion_tokens": 12, "total_tokens": 21 } }流式模式下api接口没有统计消耗的tokens
{ "id":"chatcmpl76y3gsGmxYfioodOWIFgxxxxxV", "object":"chat.completion.chunk", "created":1681895111, "model":"gpt-3.5-turbo-0301", "choices":[ { "delta":{"content":"xx""}, "index":0, "finish_reason":null } ] }
网友回复