Streaming (SSE)
PromptShuttle supports Server-Sent Events for real-time visibility into multi-agent execution. When you enable streaming on the OpenAI-compatible endpoint, you get a structured event stream covering the full lifecycle of your request — from agent starts through tool calls to final completion.
Enabling streaming
Set stream: true on the OpenAI-compatible endpoint:
curl -N -X POST https://app.promptshuttle.com/api/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o",
"messages": [{"role": "user", "content": [{"type": "text", "text": "Research quantum computing"}]}],
"stream": true,
"stream_options": {
"include_usage": true,
"usage_interval_ms": 3000
}
}'Response format
The response uses standard SSE format with Content-Type: text/event-stream:
Each event is a JSON object:
id
string
Unique event ID
timestamp
datetime
UTC ISO 8601 with milliseconds
requestId
string
Root request ID
type
string
Event type (see below)
agentPath
array
Breadcrumb of agent roles from root to current (e.g. ["main", "research_agent"])
depth
integer
Nesting depth in the agent tree
data
object
Event-specific payload
The stream ends with data: [DONE].
The response includes the header X-Request-Id with the root request ID.
Event types
Lifecycle events
requestStarted
Emitted when the request begins processing.
requestCompleted
Emitted when the entire request (including all agents) finishes.
requestFailed
Emitted if the request fails fatally.
Cancellation
A run stopped with POST /api/v1/runs/{runId}/cancel emits an error event with code: "RUN_CANCELLED", then finishes the stream normally — requestCompleted if it had produced anything, requestFailed if it had not. There is no separate terminal event, so existing clients need no changes: they see the run end where they already expect it to.
Agent events
agentStarted
An agent (sub-template) begins execution.
agentInferenceStarted
An LLM call begins within an agent.
agentInferenceCompleted
An LLM call finishes.
agentCompleted
An agent finishes all its work.
agentFailed
An agent encounters an error.
Tool events
toolStarted
A tool is about to be invoked.
For external tools, targetUrl is the endpoint the call is actually placed against — after environment bindings and any caller-supplied callback origin, not the URL stored on the definition. originSource says which of those won:
originSource
The endpoint came from
tool
The tool's base webUrl
environment
An environment override for this run's environment
callback
The caller's X-Shuttle-Callback-Url header
toolCompleted
A tool invocation finishes.
For agent-type tools, also includes:
toolFailed
A tool invocation errors. Same shape as toolCompleted with "status": "failed" and the error in resultPreview. targetUrl and originSource are repeated here so a failure is self-describing — a call that could not be bound to a host at all has no successful toolStarted to read them from.
Usage events
usageUpdate
Periodic cost and progress updates (interval controlled by usage_interval_ms).
System events
heartbeat
Keep-alive sent at heartbeat_interval_ms intervals.
error
A recoverable or non-recoverable error occurred.
Filtering events
Use event_types in stream options to receive only the events you need:
Client example
Last updated