I use https://api.openai.com/v1/chat/completions api and in every response 7 tokens is added more to prompt_tokens. but token calculation is different in documentation
For example, the string “ChatGPT is great!”
is encoded into six tokens: [“Chat”, “G”, “PT”, “ is”, “ great”, “!”]
.(OpenAI API)
Request:
{
“model”: “gpt-3.5-turbo”,
“messages”: [
{
“role”: “user”,
“content”: “ChatGPT is great!”
}
]
}
Response:
{
“id”: “chatcmpl-6rjw1m7694xfXLI77j3sqGSbFCkmV”,
“object”: “chat.completion”,
“created”: 1678265977,
“model”: “gpt-3.5-turbo-0301”,
“usage”: {
“prompt_tokens”: 13,
“completion_tokens”: 22,
“total_tokens”: 35
},
“choices”: [
{
“message”: {
“role”: “assistant”,
“content”: “\n\nI’m glad to hear that! Is there anything specific that you find great about ChatGPT?”
},
“finish_reason”: “stop”,
“index”: 0
}
]
}