From ed97c0bd5ca704b18647dd6b78a3518047618d55 Mon Sep 17 00:00:00 2001 From: bytesizedwizard Date: Tue, 12 Nov 2024 20:04:55 +0530 Subject: [PATCH] fix(example): set the 'include usage' field to true under stream options to get accurate usage information --- examples/chat-completion-accumulating/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/chat-completion-accumulating/main.go b/examples/chat-completion-accumulating/main.go index da3eac86..db99eec4 100644 --- a/examples/chat-completion-accumulating/main.go +++ b/examples/chat-completion-accumulating/main.go @@ -46,6 +46,9 @@ func main() { }), }, }), + StreamOptions: openai.F(openai.ChatCompletionStreamOptionsParam{ + IncludeUsage: openai.F(true), // Needs to be set to true in order to include usage statistics in the completion response + }), } stream := client.Chat.Completions.NewStreaming(ctx, params)