app/api/chat/route.ts):
What This Does
- Events —
requestEventandresponseEventdefine typed messages with schema validation. - Agent —
myAgentlistens foruser-request, runs logic, and emitsagent-response. - Network — The main channel receives requests; the client channel streams responses via HTTP.
- API —
expose()turns the network into an SSE endpoint;NextEndpointadapts it for Next.js.
Next
- Run + Expected Output — How to run and what you’ll see

