How do you get the usageMetadata when using a content stream?

When using the JS SDK and creating a chat stream, is there any way to get the usage metadata? As the response is being chunked back, rather than returned as an object, it’s just a pure text stream. Is the metadata still stored somewhere internally we can get at?

Hi @Richard_Davey ,

To directly access the usage metadata of a chat response chunks in genai-js, you can use chunk.usageMetadata. For more detailed information, refer to the documentation. Thank You!!