79609074

Date: 2025-05-06 16:08:19
Score: 0.5
Natty:
Report link

If you are looking for an answer to this in 2025 (or later), the easiest solution would be to install the Vercel AI SDK:

npm i ai @ai-sdk/openai @ai-sdk/react zod

and follow their Expo Guide.

Contrary to their example, I was using the useObject function instead of useChat and thought streaming wasn't possible because the server part could not use toDataStreamResponse. Turns out that is not true and you can achieve streaming with all the functions as long as you set up the headers to:

{
  "Content-Type": "application/octet-stream",
  "Content-Encoding": "none",
}

TL;DR: Just follow this guide

Reasons:
  • Blacklisted phrase (1): this guide
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Matěj Balga