Loading...

Response Text Streaming

Stream response message text from Tambo as it is being generated.

When you send a message to Tambo, Tambo will handle updating the thread's final message as data streams in rather than waiting for the entire response to complete.

Send a message to the current thread:

streaming.tsx
import { useTambo } from "@tambo-ai/react";

const { sendThreadMessage } = useTambo();
await sendThreadMessage(inputValue);

//or

const { submit } = useTamboThreadInput();
await submit();

Render your thread messages like normal.

streaming.tsx
import { useTambo } from "@tambo-ai/react";

const { thread } = useTambo();

...

<div>
  {thread.messages.map((message, index) => (
    <div
      key={index}
    >
      <div>{message.content[0].text}</div>
    </div>
  ))}
</div>;