I'm using the Vercel AI SDK with Fumadocs and I'd like to implement a simple provider for streaming data, without relying on Vercel's React hooks. I'm currently using RSC Server Actions with readStreamableValue from the AI SDK, but I'd prefer to use a dedicated /api/chat route.
I'm using tool calling, so I need to use dataStreamResponse from the /api/chat route rather than a plain textResponse.
Here's my current /api/chat route using streamText and toDataStreamResponse:
import { openai } from '@ai-sdk/openai';
import { streamText } from 'ai';
export const maxDuration = 30;
export async function POST(req: Request) {
const { messages } = await req.json();
const result = streamText({
model: openai('gpt-4o-mini'),
messages,
});
return result.toDataStreamResponse();
}
Could someone provide an example of how to consume this dataStreamResponse on the client-side, without the React SDK