Skip to main content
POST
Create a Streaming Workflow Event

Why use streaming?

By default, when you submit a workflow event, the response is delivered all at once after processing completes. Streaming lets you start receiving outputs immediately, before processing is entirely finished — perfect for chat interfaces or any application where perceived latency matters.

How it works

Add stream=true to your request, and you’ll receive a stream of Server-Sent Events instead of a single JSON response.

Streaming is supported on all run modes except precision_max and precision_max_codex.

Note: super_fast does not support Web Search or File Search. If your workflow has these capabilities enabled, either switch to a run mode that supports them (e.g. fast, precision, precision_codex) or edit the workflow to disable Web Search / File Search.

Defend evaluates the model output against your workflow’s guardrails. If the output passes, it streams back the original. If it fails, Defend improves it and streams back the improved version. Either way, you receive a single stream of token events containing the final output — just forward them to your end-user.

Event types

token: These are the output chunks. Stream them directly to your end-user as they arrive.

error: This means something went wrong, and will include a message.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

workflow_id
string
required

The ID of the workflow to create the event for.

Query Parameters

stream
boolean
default:false

Enable SSE streaming for real-time token feedback. Supported on all run modes except precision_max and precision_max_codex.

Body

application/json
model_input
object
required

The input provided to the model (e.g., prompt, messages).

model_output
string
required

The output generated by the model to be evaluated.

model_used
string
required

The model that generated the output (e.g., "gpt-4", "claude-3").

run_mode
enum<string>
required

The evaluation run mode. Streaming is supported on all run modes except precision_max and precision_max_codex. Note: super_fast does not support Web Search or File Search — if your workflow has these enabled, use a different run mode or disable the capability on the workflow.

Available options:
super_fast,
fast,
precision,
precision_codex
nametag
string

Optional tag to identify this event.

Response

A stream of Server-Sent Events delivering the output directly to your end-user.

Each event has an event: type and a data: JSON payload. You'll receive:

token — Output chunks. Stream these directly to your end-user as they arrive. If the original output passed all guardrails, the tokens contain the original. If improvement was needed, the tokens contain the improved version. Either way, you should forward them.

error — This means something went wrong and includes a message field.

The response is of type string<sse>.