From 6d8f85aedb3d01333c5299f9d65b768250e258ed Mon Sep 17 00:00:00 2001 From: Robert Craigie Date: Fri, 22 Nov 2024 19:47:40 +0000 Subject: [PATCH] docs(readme): mention `.withResponse()` for streaming request ID --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index ec17427a6..ac9c84a42 100644 --- a/README.md +++ b/README.md @@ -377,6 +377,18 @@ const completion = await client.chat.completions.create({ messages: [{ role: 'us console.log(completion._request_id) // req_123 ``` +You can also access the Request ID using the `.withResponse()` method: + +```ts +const { data: stream, request_id } = await openai.chat.completions + .create({ + model: 'gpt-4', + messages: [{ role: 'user', content: 'Say this is a test' }], + stream: true, + }) + .withResponse(); +``` + ## Microsoft Azure OpenAI To use this library with [Azure OpenAI](https://learn.microsoft.com/azure/ai-services/openai/overview), use the `AzureOpenAI`