How do I get usage information from npm azure/openai client response

Justin Liong Ching Hui 1 Reputation point
2023-08-31T09:26:22.6733333+00:00

Hi, I have installed npm@azure/openai at version 1.0.0-beta.5

As I tried to use Chat Completions service through the OpenAIClient and getChatCompletions using the library, I was able to get the response successfully, inclusive of the message, choices etc.

However, I'm not able to find the field "usages" within the response for token accumulation for users (thus limiting excessive usage, NOT rate limit, just a total usage limitation per account)]

As I read up some existing documentations, I found that the usage field is inside NuGet version 1.0.0-beta.7, does this apply to JavaScript as well? (Such that, beta.5 does not have Usage field in its chat completion response as it is only available in beta.7 and above)

If so, is there any other way with which i could get the token information?User's image

This is a simple screenshot of the full response I have received with my app's front-end.

Microsoft 365 and Office Development Office JavaScript API
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,081 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.