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

# Stream Event • Rust AI Agent SDK

> StreamEvent: A single streaming event emitted during LLM response streaming.

# StreamEvent

> Defined in the [**streaming**](../modules/streaming) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

A single streaming event emitted during LLM response streaming.

## Fields

| Name           | Type                         | Description                                |
| -------------- | ---------------------------- | ------------------------------------------ |
| `event_type`   | `StreamEventType`            | Event type                                 |
| `timestamp`    | `u64`                        | Timestamp (milliseconds since epoch)       |
| `content`      | `Option&lt;String&gt;`       | Text content for DeltaText events          |
| `tool_call`    | `Option&lt;ToolCallData&gt;` | Tool call data for DeltaToolCall events    |
| `metadata`     | `HashMap&lt;String`          | Additional metadata                        |
| `error`        | `Option&lt;String&gt;`       | Error message for Error events             |
| `is_reasoning` | `bool`                       | Whether this is reasoning/thinking content |
| `agent_id`     | `Option&lt;String&gt;`       | Agent ID for multi-agent scenarios         |
| `session_id`   | `Option&lt;String&gt;`       | Session ID for tracking                    |
| `run_id`       | `Option&lt;String&gt;`       | Run ID for correlation                     |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new(event_type: StreamEventType) -> Self
```

Create a new stream event

**Parameters:**

| Name         | Type              |
| ------------ | ----------------- |
| `event_type` | `StreamEventType` |

### `content`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn content(mut self, content: impl Into<String>) -> Self
```

Set content

**Parameters:**

| Name      | Type                      |
| --------- | ------------------------- |
| `content` | `impl Into&lt;String&gt;` |

### `tool_call`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn tool_call(mut self, tool_call: ToolCallData) -> Self
```

Set tool call

**Parameters:**

| Name        | Type           |
| ----------- | -------------- |
| `tool_call` | `ToolCallData` |

### `error`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn error(mut self, error: impl Into<String>) -> Self
```

Set error

**Parameters:**

| Name    | Type                      |
| ------- | ------------------------- |
| `error` | `impl Into&lt;String&gt;` |

### `reasoning`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn reasoning(mut self, is_reasoning: bool) -> Self
```

Set as reasoning content

**Parameters:**

| Name           | Type   |
| -------------- | ------ |
| `is_reasoning` | `bool` |

### `agent_id`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn agent_id(mut self, id: impl Into<String>) -> Self
```

Set agent ID

**Parameters:**

| Name | Type                      |
| ---- | ------------------------- |
| `id` | `impl Into&lt;String&gt;` |

### `session_id`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn session_id(mut self, id: impl Into<String>) -> Self
```

Set session ID

**Parameters:**

| Name | Type                      |
| ---- | ------------------------- |
| `id` | `impl Into&lt;String&gt;` |

### `run_id`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn run_id(mut self, id: impl Into<String>) -> Self
```

Set run ID

**Parameters:**

| Name | Type                      |
| ---- | ------------------------- |
| `id` | `impl Into&lt;String&gt;` |

### `metadata`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn metadata(mut self, key: impl Into<String>, value: impl Into<String>) -> Self
```

Add metadata

**Parameters:**

| Name    | Type                      |
| ------- | ------------------------- |
| `key`   | `impl Into&lt;String&gt;` |
| `value` | `impl Into&lt;String&gt;` |

### `request_start`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn request_start() -> Self
```

Create a request start event

### `first_token`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn first_token(content: impl Into<String>) -> Self
```

Create a first token event

**Parameters:**

| Name      | Type                      |
| --------- | ------------------------- |
| `content` | `impl Into&lt;String&gt;` |

### `delta_text`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn delta_text(content: impl Into<String>) -> Self
```

Create a delta text event

**Parameters:**

| Name      | Type                      |
| --------- | ------------------------- |
| `content` | `impl Into&lt;String&gt;` |

### `stream_end`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn stream_end() -> Self
```

Create a stream end event

### `error_event`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn error_event(message: impl Into<String>) -> Self
```

Create an error event

**Parameters:**

| Name      | Type                      |
| --------- | ------------------------- |
| `message` | `impl Into&lt;String&gt;` |

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/streaming/mod.rs#L119">
  `praisonai/src/streaming/mod.rs` at line 119
</Card>
