Skip to content

Commit 7c7b9f2

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 7c7b9f2

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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)