Skip to Content
The Ngamia platform API is in preview. Endpoints may change before general availability.
GuidesStream run events

Stream run events

Start the run with "wait": false, then read its events as Server-Sent Events :

RUN=$(curl -s https://api.ngamia.com/v1/agents/duka-helper/runs \ -H "Authorization: Bearer $NGAMIA_KEY" -H 'content-type: application/json' \ -d '{"input":"Bei ya simu ya Tecno Spark ni ngapi?","user":"customer-42","wait":false}' | jq -r .run_id) curl -N "https://api.ngamia.com/v1/runs/$RUN/events?user=customer-42" \ -H "Authorization: Bearer $NGAMIA_KEY"
id: 0 event: run.started data: {"agent":"duka-helper","thread_id":null,"previous_run_id":null,"run_id":"…","seq":0,"at_ms":1764240000000} id: 1 event: model.replied data: {"text":null,"tool_calls":[{"id":"call_1","name":"knowledge_search","args":{"query":"bei Tecno Spark"}}],"input_tokens":812,"output_tokens":24,"run_id":"…","seq":1,"at_ms":…} id: 2 event: tool.started … event: run.completed data: {"output":"…","run_id":"…","seq":5,"at_ms":…}
Eventdata fields
run.startedagent, thread_id, previous_run_id
model.repliedtext, tool_calls (id, name, args), input_tokens, output_tokens
tool.startedcall_id
tool.finishedcall_id, is_error, output
approval.requested, approval.resolvedapproval details (not used by platform agents in this release)
run.completedoutput
run.failederror
run.cancelledreason

Every event also has run_id, seq (also the SSE id) and at_ms.

  • Resume after a dropped connection with the Last-Event-ID header set to the last id you saw. No events are lost.
  • The stream ends after a terminal event (run.completed, run.failed, run.cancelled).
  • Pass the same user the run was started with.
  • In browsers, stream through your own server so the API key stays private.