Agent Streaming
How to use streaming in your agents
Streaming lets your users read the response before the AI finishes thinking. Nothing feels faster than already happening.
Why Streaming?
- Latency hiding by showing results instantly instead of after the whole response is ready.
- Large inputs and outputs without hitting payload limits.
- Agent chains can forward chunks to the next agent as soon as they arrive.
- Snappier UX so users see progress in milliseconds instead of waiting for the full payload.
- Resource efficiency by not holding entire responses in memory; chunks flow straight through.
- Composable pipelines by allowing agents, functions, and external services to hand off work in a continuous stream.
A simple visualization of the difference between traditional request/response and streaming:
Real-World Use Cases
- Live chat / customer support. Stream the assistant's words as they are generated for a more natural feel.
- Speech-to-text. Pipe microphone audio into a transcription agent and forward captions to the UI in real time.
- Streaming search results. Show the first relevant hits immediately while the rest are still processing.
- Agent chains. One agent can translate, the next can summarize, the third can analyze – all in a single flowing stream.
How Streaming Works in Agentuity
- Outbound:
resp.stream(source)
– wheresource
can be:- An async iterator (e.g. OpenAI SDK stream)
- A ReadableStream
- Another agent's stream
- Inbound:
await request.data.stream()
– consume the client's incoming stream. - Under the hood Agentuity handles the details of the streaming input and output for you.
OpenAI Streaming Example
In this example, we use the OpenAI SDK to stream the response from the OpenAI API back to the caller.
Agent-to-Agent Streaming
In this example, we use the Agentuity SDK to stream the response from one agent to another.
Chain as many agents as you like; each one can inspect, transform, or just relay the chunks.
Further Reading
- Blog Post: Agents just want to have streams
- SDK Examples: JavaScript · Python
- Streaming Video Demo: Watch on YouTube
Need Help?
Join our Community for assistance or just to hang with other humans building agents.
Send us an email at hi@agentuity.com if you'd like to get in touch.
Please Follow us on
If you haven't already, please Signup for your free account now and start building your first agent!