> ## Documentation Index
> Fetch the complete documentation index at: https://www.adaline.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# LogSpanModelStreamContent

# LogSpanModelStreamContent

Content type for streaming LLM inference spans.

## Overview

`LogSpanModelStreamContent` captures streaming model calls where individual chunks are collected alongside an aggregated final output. It is wrapped in a [LogSpanContent](/docs/reference/sdk/v2/python/types/LogSpanContent) union via the `actual_instance` pattern.

```python theme={null}
from adaline_api.models.log_span_model_stream_content import LogSpanModelStreamContent
```

***

## Fields

<ParamField body="type" type="str" required>
  Must be `"ModelStream"`.
</ParamField>

<ParamField body="provider" type="str" required>
  The provider name (e.g., `"openai"`, `"anthropic"`). 1–512 characters.
</ParamField>

<ParamField body="model" type="str" required>
  The model identifier (e.g., `"gpt-4o"`, `"claude-sonnet-4-20250514"`). 1–512 characters.
</ParamField>

<ParamField body="input" type="str" required>
  The input payload as a JSON string. Must be valid, parseable JSON (the result of `json.dumps()`).
</ParamField>

<ParamField body="output" type="str" required>
  The raw streamed output. Typically the concatenated chunk payloads collected during streaming.
</ParamField>

<ParamField body="aggregate_output" type="str" required>
  The aggregated final output as a JSON string. Must be valid, parseable JSON.
</ParamField>

<ParamField body="variables" type="LogSpanVariable | None" optional>
  Variable associated with this span for evaluation tracking. See [LogSpanVariable](/docs/reference/sdk/v2/python/types/LogSpanVariable).
</ParamField>

<ParamField body="cost" type="float | None" optional>
  Cost of inference in USD. Overrides the automatic cost calculated by Adaline. Minimum: 0.
</ParamField>

***

## Construction Pattern

All span content is wrapped in [LogSpanContent](/docs/reference/sdk/v2/python/types/LogSpanContent) using the `actual_instance` parameter:

```python theme={null}
from adaline_api.models.log_span_content import LogSpanContent
from adaline_api.models.log_span_model_stream_content import LogSpanModelStreamContent

content = LogSpanContent(
    actual_instance=LogSpanModelStreamContent(
        type="ModelStream",
        provider="anthropic",
        model="claude-sonnet-4-20250514",
        input=json.dumps(params),
        output=raw_chunks,
        aggregate_output=json.dumps(aggregated),
    )
)
```

***

## Example

```python theme={null}
import json
from adaline_api.models.log_span_content import LogSpanContent
from adaline_api.models.log_span_model_stream_content import LogSpanModelStreamContent

params = {
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Write a haiku."}],
    "stream": True,
}

span.update({
    "status": "success",
    "content": LogSpanContent(
        actual_instance=LogSpanModelStreamContent(
            type="ModelStream",
            provider="openai",
            model="gpt-4o",
            input=json.dumps(params),
            output=collected_chunks,
            aggregate_output=json.dumps({"role": "assistant", "content": full_text}),
            cost=0.003,
        )
    ),
})
```
