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:

Field
Type
Description

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.

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.

toolCompleted

A tool invocation finishes.

For agent-type tools, also includes:

toolFailed

A tool invocation errors.

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