Stream a function call execution in real-time using Server-Sent Events (SSE).
This endpoint provides continuous streaming of function execution results, supporting both unstructured text streaming and structured JSON streaming with precise field tracking.
Text Mode (no output_schema):
delta fieldchunk_type will be “text”Structured Mode (with output_schema):
json_pathchunk_type will be “json”When using output_schema, each streaming chunk includes a json_path field showing exactly
which field in your schema is being populated:
response.summary → Top-level string fieldresponse.people[0].name → Name of first person in arrayresponse.people[1].role → Role of second personresponse.metadata.created_at → Nested object fieldThis enables precise UI updates where you can route streaming content to specific components based on the path, creating responsive real-time interfaces.
Each Server-Sent Event contains:
id: Optional event identifierevent: Optional event type (typically “message”)data: StreamingChunk with the actual streaming contentretry: Optional retry interval for reconnectionThe StreamingChunk data payload varies by mode:
Text Mode:
delta: Incremental text contentspan_id: Execution span ID (first chunk)chunk_type: “text”Structured Mode:
delta: Actual field values being streamedjson_path: Dot-notation path to current fieldspan_id: Execution span ID (first chunk)chunk_type: “json”Text streaming events:
data: {"span_id": "123e4567-e89b-12d3-a456-426614174000"}
data: {"delta": "Hello", "chunk_type": "text"}
data: {"delta": " world", "chunk_type": "text"}
Structured streaming events:
data: {"span_id": "123e4567-e89b-12d3-a456-426614174000"}
data: {"delta": "John", "json_path": "response.name", "chunk_type": "json"}
data: {"delta": " Doe", "json_path": "response.name", "chunk_type": "json"}
data: {"delta": "Engineer", "json_path": "response.role", "chunk_type": "json"}
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Provide a unique name of the task. A function with this name will be created in the project. Functions configuration is overridden by the request parameters.
Optionally provide an instruction for the model to complete the task. Recommended to be concise and to the point
"Calculate the sum of two numbers"
Optionally provide an input schema for the task. Can preferably include field descriptions to allow the model to reason about the input variables. Schema is validated against the input data and issues an error if it does not match. With the Opper SDKs you can define these schemas through libraries like Pydantic and Zod. For schemas with definitions, prefer using '$defs' and '#/$defs/...' references.
{
"properties": {
"x": { "title": "X", "type": "integer" },
"y": { "title": "Y", "type": "integer" }
},
"required": ["x", "y"],
"title": "OpperInputExample",
"type": "object"
}Optionally provide an output schema for the task. Response is guaranteed to match the schema or throw an error. Can preferably include field descriptions to allow the model to reason about the output variables. With the Opper SDKs you can define these schemas through libraries like Pydantic and Zod. For schemas with definitions, prefer using '$defs' and '#/$defs/...' references.
Streaming with output_schema: When used with streaming endpoints, enables precise field tracking via json_path. Each streaming chunk includes the exact schema field being populated (e.g., 'response.people[0].name'), allowing real-time UI updates by routing content to specific components.
{
"properties": {
"sum": { "title": "Sum", "type": "integer" }
},
"required": ["sum"],
"title": "OpperOutputExample",
"type": "object"
}Optionally provide input data as context to complete the task. Could be a text, image, audio or a combination of these.
{ "x": 4, "y": 5 }Optionally provide a model to use for completing the task.
If not provided, a default model will be used. Currently the default model is azure/gpt-4o-eu
To specify options for the model, use a dictionary of key-value pairs. The options are passed to the model on invocation.
An example of passing temperature to gpt-4o-mini hosted on OpenAI is shown below.
{
"model": "openai/gpt-4o-mini", # the model name
"options": {
"temperature": 0.5 # the options for the model
}
}To specify a fallback model, use a list of models. The models will then be tried in order. The second model will be used if the first model is not available, and so on.
[
"openai/gpt-4o-mini", # first model to try
"openai/gpt-4.1-nano", # second model to try
]{
"extra_headers": {},
"name": "openai/gpt-4o-mini",
"options": { "temperature": 0.5 }
}Optionally provide examples of successful task completions. Will be added to the prompt to help the model understand the task from examples.
[
{
"comment": "Adds two numbers",
"input": { "x": 1, "y": 3 },
"output": { "sum": 4 }
}
]Optionally provide the parent span ID to add to the call event. This will automatically tie the call to a parent span in the UI.
"123e4567-e89b-12d3-a456-426614174000"
Optionally provide a list of tags to add to the call event. Useful for being able to understand aggregate analytics on some dimension.
{
"project": "project_456",
"user": "company_123"
}Optional configuration for the function.Configuration is a dictionary of key-value pairs that can be used to override the default configuration for the function.
{
"beta.invocation.input_validation.enabled": false,
"beta.invocation.xml_mode.enabled": false,
"invocation.cache.ttl": 0,
"invocation.few_shot.count": 3,
"invocation.structured_generation.max_attempts": 5
}Server-Sent Events stream of function execution chunks
Server-Sent Event following the SSE specification
Represents the data payload within a Server-Sent Event for streaming function execution.
This model contains the JSON content sent in the 'data' field of each SSE event. The fields present depend on the streaming mode:
Text Mode (no output_schema):
delta field for incremental text contentchunk_type will be "text"Structured Mode (with output_schema):
delta and json_path for precise field trackingchunk_type will be "json"JSON Path Examples:
response.summary - Top-level string fieldresponse.people[0].name - Name of first person in arrayresponse.metadata.created_at - Nested object fieldEvent ID for the SSE event
"123"
Event type for the SSE event
"message"
Retry interval in milliseconds for the SSE connection
1000