Iter Stream • AI Agent SDK

iter_stream: Stream agent response as an iterator of chunks.

iter_stream

Method

</div>

This is a method of the Agent class in the agent module.

Stream agent response as an iterator of chunks.

App-friendly streaming. Yields response chunks without terminal display. Use this for building custom UIs or processing streams programmatically.

Signature

python
def iter_stream(prompt: str) -> Any

Parameters

ParamField str

The input prompt to process **kwargs: Additional arguments: – display (bool): Show terminal output. Default: False – output (str): Output preset override

Returns

ResponseField Any

The result of the operation.

Usage

python
agent = Agent(instructions="You are helpful")

    # Process stream programmatically
    full_response = ""
    for chunk in agent.iter_stream("Tell me a story"):
        full_response += chunk
        # Custom processing here

    # Or collect all at once
    response = "".join(agent.iter_stream("Hello"))

Source

View on GitHub

praisonaiagents/agent/agent.py at line 6368