# Streaming Agent API (experimental)

Some of the LLM packages, like open-ai, has a streaming version of the `Chat Complete` function.

<figure><img src="/files/aM8kLBqKj5Us1cpDyCMC" alt=""><figcaption></figcaption></figure>

To use the streamed API, first call `Chat Complete Streamed`, and then call `Next Event` in a loop, to handle all streamed events.

The streamed API supports tool calls and structured output as well. However, unlike `Chat Complete`, it won't automatically call the LLM again after a set of tool calls is complete. You can do this yourself by appending the tool call results to the context, and then looping back to the `Chat Complete Streamed`, like so:

<figure><img src="/files/91TvHnef5Um0XKL8gmCq" alt=""><figcaption></figcaption></figure>

In the example above, we explicitly create a message list, instead of using the `system message` and `user message` inputs. This is just to make it easier to manage the context when we loop back after tool calls. Another approach would be to use two separate calls to chat complete, one that handles tool calls, and then one that summarizes the results.

<figure><img src="/files/PAEw2tRoDF5KxmCiKzHv" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.midio.com/midio-docs/guides/building-agents/streaming-agent-api-experimental.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
