SynupAgent
Créer une clé
AgentStreaming

Streaming

stream_url, returned with every dispatch, is a plain SSE endpoint — no library needed, any HTTP client that reads a chunked response works. It carries its own short-lived token, so it's safe to hand to a browser-side client directly without exposing your real API key.

What you get

Two frame kinds: status(the agent's progress — the same trace a person sees in the Sydekick panel: thinking, which tool it's using) and content (the final reply). A closing done frame ends the stream.

event: status
data: {"seq": 1, "text": "thinking"}

event: status
data: {"seq": 2, "text": "tool_started: get_reviews"}

event: content
data: {"seq": 3, "text": "Your average rating this month is 4.6..."}

event: done
data: {"status": "completed"}

seq is the ordering guarantee, not arrival order — treat it as the source of truth if you ever see frames arrive out of sequence.

Resuming a dropped connection

Pass starting_after with the last seq you saw — the event log, not the live connection, is the source of truth, so nothing is lost and the agent turn is never restarted.

# Connection dropped after seq 2 — reconnect from exactly there,
# nothing lost, the agent turn is never restarted.
curl "https://ai.synup.com/api/v1/agent/stream?token=...&starting_after=2"

The token expires in 5 minutes

A long agent turn can outlive that. The dispatch response also includes a stream_refresh_token — exchange it for a fresh stream_url before the old one expires:

curl -X POST https://ai.synup.com/api/v1/agent/stream/token \
  -H "Content-Type: application/json" \
  -d '{"task_id": "task_9f2c...", "refresh_token": "..."}'
{
  "data": { "stream_url": "https://ai.synup.com/api/v1/agent/stream?token=..." }
}