Backend
Open the file at the following location: app/api/chat/route.ts
.
You should see the following code which defines a POST request at the /api/chat
endpoint.
Pull in the messages
from the request body.
Import and call streamText
, passing in a model and the messages.
Return the model's response using the toAIStreamResponse
helper method on result
.