Streaming without useChat
Unanswered
Lilac posted this in #help-forum
LilacOP
Hi, I am working on a side project (without completing the previous one 🙂 ), what I want to achieve is that whenever I will click on a button, a request to the OpenAI API should be sent and get the streaming output. I have heard of useChat and useCompletion. I don't think that's what I need. Is there any other option where I can host the OpenAI backend on /chat endpoint and have streaming working on the front-end (without using useChat)
2 Replies
You can do this with the ai sdk in route handlers
https://nextjs.org/docs/app/building-your-application/routing/route-handlers#streaming
https://nextjs.org/docs/app/building-your-application/routing/route-handlers#streaming
LilacOP
How can I use it on the front-end?