POST
/
functions
/
{function_id}
/
call
/
stream
/
{revision_id}
Stream Function Revision
import requests

url = "https://api.opper.ai/v2/functions/{function_id}/call/stream/{revision_id}"

payload = {
    "input": "<any>",
    "parent_span_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "examples": [
        {
            "comment": "Adds two numbers",
            "input": {
                "x": 1,
                "y": 3
            },
            "output": { "sum": 4 }
        }
    ],
    "tags": { "tag": "value" }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
{
  "data": {
    "delta": "Hello! How can I assist you today?",
    "span_id": "123e4567-e89b-12d3-a456-426614174000"
  }
}

Authorizations

Authorization
string
header
required

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

Path Parameters

function_id
string<uuid>
required

The id of the function to call

revision_id
string<uuid>
required

The id of the revision to call

Body

application/json
input
any

Input to the function

parent_span_id
string<uuid> | null
examples
ExampleIn · object[] | null
Examples:
[
{
"comment": "Adds two numbers",
"input": { "x": 1, "y": 3 },
"output": { "sum": 4 }
}
]
tags
object | null

Tags to add to the call event

Examples:
{ "tag": "value" }

Response

Server-Sent Events stream of function execution chunks

Server-Sent Event following the SSE specification

data
object
required

The actual data payload containing streaming chunk information

id
string

Event ID for the SSE event

Example:

"123"

event
string

Event type for the SSE event

Example:

"message"

retry
integer

Retry interval in milliseconds for the SSE connection

Example:

1000