Skip to content

Streaming

Streaming is enabled through provider options and runtime-specific stream APIs. Callers usually request a raw streaming provider response, then pass it through process to get clean chunks.

agent = prompty.load("chat.prompty")
messages = prompty.prepare(agent, inputs={"q": "Hi"})
agent.model.options.additionalProperties = {"stream": True}
response = prompty.run(agent, messages, raw=True)
for chunk in prompty.process(agent, response):
print(chunk, end="", flush=True)
TypeDescription
PromptyStreamSync stream wrapper with tracing support
AsyncPromptyStreamAsync stream wrapper with tracing support
StreamChunkSchema-level chunk union for text, thinking, tool, and error chunks

For schema details, see StreamChunk and StreamOptions.