Send Message (Streaming)
Send a message to an agent session and receive a streaming response.Session ID (e.g.,
ses_xyz789)Message to send to the agent
Server-Sent Events (SSE)
The response is a stream of Server-Sent Events. Each event has atype and data field.
Event Format
Run Event Types
message.delta
Streamed text chunk from the agent’s response.Always
"message.delta"Text content to append to the response
tool.start
Agent started using a tool.Always
"tool.start"Name of the tool being invoked
Input parameters passed to the tool
tool.end
Tool invocation completed.Always
"tool.end"Tool execution time in milliseconds
run.started
Run has started processing.Always
"run.started"Empty object or metadata
run.completed
Run finished successfully.Always
"run.completed"Total run duration in milliseconds
Whether the agent hit its maximum turn limit
Message explaining the turn limit if reached
run.failed
Run encountered an error.Always
"run.failed"Error message describing what went wrong
run.cancelled
Run was cancelled by the user or system.Always
"run.cancelled"Empty object or cancellation metadata
status
General status update from the agent.Always
"status"Status information (structure varies)
heartbeat
Keep-alive event to prevent connection timeout.Always
"heartbeat"Empty object
TypeScript Example
Using the SDK
The Superserve SDK handles SSE parsing automatically:Error Responses
If the request fails before streaming starts, you’ll receive a standard HTTP error response:HTTP status code
Error message
Additional error context
| Status | Message |
|---|---|
| 401 | Not authenticated |
| 404 | Session not found |
| 422 | Invalid message format |
| 429 | Rate limit exceeded |
run.failed events.