---
title: "Function Stream"
method: POST
path: "/call/stream"
tags: ["calls"]
---

# Function Stream

`POST /call/stream`

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.

## Streaming Modes

**Text Mode (no output_schema):**
- Streams incremental text content via the `delta` field
- `chunk_type` will be "text"
- Best for conversational AI, creative writing, open-ended responses

**Structured Mode (with output_schema):**
- Streams structured JSON with precise field tracking via `json_path`
- `chunk_type` will be "json"
- Enables real-time UI updates by showing which schema field is being populated
- Perfect for forms, dashboards, structured data display

## JSON Path Feature

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 field
- `response.people[0].name` → Name of first person in array
- `response.people[1].role` → Role of second person
- `response.metadata.created_at` → Nested object field

This enables precise UI updates where you can route streaming content to specific components
based on the path, creating responsive real-time interfaces.

## Response Structure

Each Server-Sent Event contains:
- `id`: Optional event identifier
- `event`: Optional event type (typically "message")
- `data`: StreamingChunk with the actual streaming content
- `retry`: Optional retry interval for reconnection

The StreamingChunk data payload varies by mode:

**Text Mode:**
- `delta`: Incremental text content
- `span_id`: Execution span ID (first chunk)
- `chunk_type`: "text"

**Structured Mode:**
- `delta`: Actual field values being streamed
- `json_path`: Dot-notation path to current field
- `span_id`: Execution span ID (first chunk)
- `chunk_type`: "json"

## Examples

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"}
```

## Request body

- AppApiPublicV2FunctionCallCallFunctionRequest
  - `name` string, required — 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.
  - `instructions` string, nullable — Optionally provide an instruction for the model to complete the task. Recommended to be concise and to the point
  - `input_schema` object, nullable — 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.
  - `output_schema` object, nullable — 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.
  - `input` unknown
  - `model` union
    - string
    - Model
      - `name` string, required
      - `extra_headers` object, nullable
      - `options` object, nullable
    - object
    - union[]
      - union
        - string
        - Model
          - `name` string, required
          - `extra_headers` object, nullable
          - `options` object, nullable
        - object
  - `examples` Example[], nullable — Optionally provide examples of successful task completions. Will be added to the prompt to help the model understand the task from examples.
    - `input` unknown, required
    - `output` unknown, required
    - `comment` string, nullable
  - `parent_span_id` string, uuid, nullable — 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.
  - `tags` object, nullable — Optionally provide a list of tags to add to the call event. Useful for being able to understand aggregate analytics on some dimension.
  - `configuration` FunctionCallConfigurationInput
    - `invocation.few_shot.count` integer — [DEPRECATED via /call] This field is ignored when passed via /call endpoint. The system enforces a default of 3. Configure via PATCH /v2/functions/{uuid} or the Platform UI instead. The number of few-shot examples to use for the call, selected using nearest neighbor search of the function's dataset.
    - `beta.evaluation` unknown
    - `invocation.structured_generation.max_attempts` integer — The maximum number of attempts to make when generating a response matching the output schema if provided.
    - `invocation.cache.ttl` integer — The time to live for the cache in seconds. If 0, the cache is disabled.
    - `beta.invocation.input_validation.enabled` boolean — Whether to enable input validation against the input schema. This is a beta feature and is disabled by default.
    - `beta.invocation.xml_mode.enabled` boolean — Experimental: enable XML structured output. The model receives an XML schema and its response is converted back to JSON. We have observed better adherence to multi-paragraph text fields (especially with Anthropic models) when this is enabled.

## Response `200`

Server-Sent Events stream of function execution chunks

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `402` — Payment Required (out of credits)
- `404` — Not Found
- `422` — Request Validation Error

---

[API](https://skmtc.dev/opper/apis/opper-api-v2.md) · [All operations](https://skmtc.dev/opper/apis/opper-api-v2/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/opper/opper-api-v2/revisions/d3ccdaa15678/schema)
