UNPKG

ai

Version:

AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.

33 lines (23 loc) 947 B
--- title: useChat No Response description: Troubleshooting errors related to the Use Chat Failed to Parse Stream error. --- # `useChat` No Response ## Issue I am using [`useChat`](/docs/reference/ai-sdk-ui/use-chat). When I log the incoming messages on the server, I can see the tool call and the tool result, but the model does not respond with anything. ## Solution To resolve this issue, convert the incoming messages to the `ModelMessage` format using the [`convertToModelMessages`](/docs/reference/ai-sdk-ui/convert-to-model-messages) function. ```tsx highlight="9" import { openai } from '@ai-sdk/openai'; import { convertToModelMessages, streamText } from 'ai'; __PROVIDER_IMPORT__; export async function POST(req: Request) { const { messages } = await req.json(); const result = streamText({ model: __MODEL__, messages: await convertToModelMessages(messages), }); return result.toUIMessageStreamResponse(); } ```