Next.js Discord

Discord Forum

How to handle Ollama streaming in Next.js?

Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
Hi folk 👋 I learnt about Ollama on Hacker News and found out that it provides a REST API. So I thought to create a Next.js app and create a playground with it. So after installing Ollama on my local machine and hitting the endpoint
curl -X POST http://localhost:11434/api/generate -d '{
  "model": "orca-mini",
  "prompt":"Why is the sky blue?"

I found that it returns a stream of data (of course!) and then I checked the Next.js documentation and found Streaming section but I wonder how can i handle the stream when the API is already on my local machine and I don't need to provide an API key?

0 Replies