11---
2- title : experimental_AssistantResponse
2+ title : AssistantResponse
33layout :
44 toc : false
55---
66
77import { Callout } from ' nextra-theme-docs' ;
88
9- # ` experimental_AssistantResponse `
9+ # ` AssistantResponse `
1010
11- The ` experimental_AssistantResponse ` class allows you to send a stream of assistant update to ` experimental_useAssistant ` .
11+ The ` AssistantResponse ` allows you to send a stream of assistant update to ` useAssistant ` .
1212
13- <Callout >
14- The ` experimental_ ` prefix indicates that the API is not yet stable and may
15- change in the future without a major version bump.
16- </Callout >
13+ ## ` AssistantResponse(settings: AssistantResponseSettings, process: AssistantResponseCallback): Response ` [ #assistantresponse]
1714
18- ## ` experimental_AssistantResponse(settings: AssistantResponseSettings, process: AssistantResponseCallback): Response ` [ #assistantresponse]
19-
20- The ` experimental_AssistantResponse ` class is designed to facilitate streaming assistant responses to the ` useAssistant ` hook.
15+ The ` AssistantResponse ` is designed to facilitate streaming assistant responses to the ` useAssistant ` hook.
2116It receives an assistant thread and a current message, and can send messages and data messages to the client.
2217
2318## Parameters
2419
2520### ` settings: {threadId: string, messageId: string} `
2621
27- You can pass the thread and the latest message into the ` experimental_AssistantResponse ` . This establishes the context for the response.
22+ You can pass the thread and the latest message into the ` AssistantResponse ` . This establishes the context for the response.
2823
2924- ` threadId: string ` : The thread ID that the response is associated with.
3025- ` messageId: string ` : The ID of the latest message that the response is associated with.
@@ -42,13 +37,13 @@ It gets invoked with the following functions that you can use to send messages a
4237
4338### Server-Side Implementation
4439
45- This example highlights the usage of ` experimental_AssistantResponse `
40+ This example highlights the usage of ` AssistantResponse `
4641for an OpenAI assistant within a Next.js environment.
4742
4843Server:
4944
5045``` tsx filename="app/api/assistant/route.ts"
51- import { experimental_AssistantResponse } from ' ai' ;
46+ import { AssistantResponse } from ' ai' ;
5247import OpenAI from ' openai' ;
5348
5449// Create an OpenAI API client (that's edge friendly!)
@@ -83,7 +78,7 @@ export async function POST(req: Request) {
8378 content: input .message ,
8479 });
8580
86- return experimental_AssistantResponse (
81+ return AssistantResponse (
8782 { threadId , messageId: createdMessage .id },
8883 async ({ forwardStream , sendDataMessage }) => {
8984 // Run the assistant on the thread
0 commit comments