Calculate OpenAI usage for Chat Completion API stream in NodeJS
Introduction
OpenAI does have the usage field in its non-stream response.
For example with a non-stream request like this (stream: false):
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": ...
anvodev.hashnode.dev6 min read