Skip to content

Commit f802262

Browse files
author
Developer
committed
Add stream_options for token usage tracking in streaming responses
X.AI supports the OpenAI standard stream_options parameter to include token usage information in streaming responses. This ensures token usage is properly tracked when using streaming mode.
1 parent f9fa972 commit f802262

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/grok/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export class GrokClient {
114114
temperature: 0.7,
115115
max_tokens: 4000,
116116
stream: true,
117+
stream_options: { include_usage: true },
117118
};
118119

119120
// Add search parameters if specified

0 commit comments

Comments
 (0)