I’m testing streamed responses from the Grok API and need to record token usage for each request. With a non-streaming response, usage information is straightforward to log; with streaming, I’m not sure what the final event is expected to contain.
For those who have built against the API, does the stream include final usage details by default, or is there a request option or follow-up step needed? I’d also like to know how you handle a client disconnecting before the stream finishes, since that could leave usage records incomplete.
Can you answer this question?
Write Answer0 Answers