How do I build a streaming /api/chat endpoint with opencode SDK?
This post might have stale content, as dev is 7978 commits ahead.
say i want to create an /api/chat endpoint, towards which i can send messages and it (ideally streams) sends me responses? how do i build that with opencode SDK? imagine i'm on next.js and have an opencode SDK server already running at https://my-opencode-server.com
cool. so imagine the user sends a message and sees the stream. then they refresh: what do they see? what's loaded?
gotchu. and if there's a message that's currently streaming? i'd do this?
.messages()
.subscribe()
? like a "re-connect while a stream is ongoing" kind of scenario
what about the storage part? if i want to have more metadata associated with, say, a session. is that recommended? would i need to eject to storing stuff in my database?
END OF POST