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

# Streaming

> Stream a conversation with an AI Agent

When conversing, you can set `"stream": true` to incrementally stream the response using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent%5Fevents/Using%5Fserver-sent%5Fevents) (SSE).

## Streaming with SDKs

Both the [Python](https://github.com/DatagridAI/datagrid-python) and [Typescript/Javascript](https://github.com/DatagridAI/datagrid-node) SDKs provide convenient APIs to stream responses.

<CodeGroup>
  ```python Python theme={null}
  from datagrid_ai import Datagrid

  datagrid = Datagrid()
  response = datagrid.converse(
      prompt="prompt",
      stream=True,
  )

  for event in response:
      if (event.event == "delta"):
          print(event.delta.text)
  ```

  ```javascript JavaScript theme={null}
  import Datagrid from "datagrid-ai";

  const datagrid = new Datagrid();

  const response = await datagrid.converse({ prompt: "prompt", stream: true });

  for await (const event of response) {
    if (event.event === "delta") {
      console.log(event.data.delta.text);
    }
  }
  ```
</CodeGroup>

## Event types

Each server-sent event includes a named event type and associated JSON data. Each event will use an SSE event name (e.g., event: delta), and include the matching event type in its data.

Each stream uses the following event flow:

1. `start`: Indicates the start of the conversation and contains the `conversation_id` and `agent_id` used to answer the prompt.
2. `delta`: contains the `delta` object with the changes to the message.
3. `end`: Indicates the end of the conversation.
