OpenAI-API-dotnet
OpenAI-API-dotnet copied to clipboard
MostResentAPIResult.Usage is null
After using Chat.StreamResponseEnumerableFromChatbotAsync() in Streaming, the Usage of Chat.MostResetAPIResult is always null. How can I obtain 'Usage' related information
var chat = _openAI.Client().Chat.CreateConversation();
chat.AppendUserInput("How to make bread ?");
await foreach (var res in chat.StreamResponseEnumerableFromChatbotAsync())
.
{
await Clients.Client(connectionId).SendAsync("ChatGPTMessage", res);
}
var result = chat.MostResentAPIResult;
result.Usage is null
Can someone explain? Thank you very much
Look forward to your help @OkGoDoIt
Hoping this can get looked at as well.
I saw the 1.8 update changed some stuff, this is unfortunately still coming out null for me too.
When streaming results, OpenAI does not provide usage details. Unfortunately this is a limitation of the OpenAI API and there's nothing I can do about it 😢 See this support thread: https://community.openai.com/t/openai-api-get-usage-tokens-in-response-when-set-stream-true/141866/18
Thank you for the swift response and clarification