Stream agent responses token by token in real time.
Stream agent responses to display output as it is generated.
1
Create the agent
agent_streaming.py
from definable.agent import Agentagent = Agent( model="gpt-4o", instructions="You are a storyteller. Write vivid, engaging stories.",)# Sync streamingfor event in agent.run_stream("Tell me a story about a robot discovering art."): if event.event == "RunContent" and event.content: print(event.content, end="", flush=True) elif event.event == "ToolCallStarted": print(f"\n> Calling {event.tool.tool_name}...") elif event.event == "RunCompleted": print(f"\n\nTokens: {event.metrics.total_tokens}")
2
Install dependencies
pip install definable
uv pip install definable
poetry add definable
3
Export your API key
export OPENAI_API_KEY=sk-***
setx OPENAI_API_KEY sk-***
4
Run
python agent_streaming.py
Tokens appear in your terminal as they are generated.
Async Streaming
import asynciofrom definable.agent import Agentagent = Agent(model="gpt-4o", instructions="You are a helpful assistant.")async def main(): async for event in agent.arun_stream("Explain quantum computing."): if event.event == "RunContent" and event.content: print(event.content, end="", flush=True)asyncio.run(main())
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Definable AI","colors":{"primary":"#FA8112","light":"#FA8112","dark":"#FA8112"},"logo":{"light":"https://mintcdn.com/definableaiprivatelimited/mDNvZulDI7LGheEl/logo/light.svg?fit=max\u0026auto=format\u0026n=mDNvZulDI7LGheEl\u0026q=85\u0026s=4b85977f6a03ffc7ceaa9b818e5d7990","dark":"https://mintcdn.com/definableaiprivatelimited/mDNvZulDI7LGheEl/logo/dark.svg?fit=max\u0026auto=format\u0026n=mDNvZulDI7LGheEl\u0026q=85\u0026s=88f4a2faa73881a1af38ae9e48f83c11"},"favicon":"/favicon.svg","background":{"color":{"light":"#FAF3E1","dark":"#222222"}},"navbar":{"links":[{"href":"https://github.com/definable-ai/definable","label":"GitHub"}]},"footer":{"socials":{"github":"https://github.com/definable-ai"}},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"GitHub","icon":"github","href":"https://github.com/definable-ai/definable"},{"anchor":"PyPI","icon":"cube","href":"https://pypi.org/project/definable-ai/"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"definableaiprivatelimited","hasAudioNarration":false,"actualSubdomain":"definableaiprivatelimited","customDomains":["docs.definable.ai"],"gitSource":{"type":"github","owner":"definableai","repo":"definable.ai","deployBranch":"main","contentDirectory":"definable/docs","isPrivate":true,"mountPath":"","label":"","_id":"6b10d3309ffae5051c40c07e"},"entitlements":{},"buildId":"6ae94795d69537c8ab6fa802:success","clientVersion":"0.0.4453","searchFilterCounts":[{"language":"default","tag":"Documentation","count":127},{"language":"default","tag":"Basics","count":48},{"language":"default","tag":"Capabilities","count":41},{"language":"default","tag":"Examples","count":36},{"language":"default","tag":"Advanced","count":34},{"language":"default","tag":"Models","count":19},{"language":"default","tag":"Usage","count":17},{"language":"default","tag":"Interfaces","count":17},{"language":"default","tag":"Tools","count":15},{"language":"default","tag":"Agents","count":12}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"auth-vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"agents/usage/agent-with-streaming","slug":"/agents/usage/agent-with-streaming","pageMetadata":{"title":"Agent with Streaming","description":"Stream agent responses token by token in real time.","href":"/agents/usage/agent-with-streaming","hidden":false},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Stream agent responses token by token in real time.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Heading,Step,Steps}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Step)_missingMdxReference(`Step`,true);if(!Steps)_missingMdxReference(`Steps`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Stream agent responses to display output as it is generated.`}),`\n`,_jsxs(Steps,{children:[_jsx(Step,{title:`Create the agent`,children:_jsx(CodeBlock,{filename:`agent_streaming.py`,numberOfLines:`15`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`15`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` definable.agent `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Agent`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`agent `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Agent(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gpt-4o\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` instructions`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"You are a storyteller. Write vivid, engaging stories.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Sync streaming`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` agent.run_stream(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Tell me a story about a robot discovering art.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event.event `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"RunContent\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` and`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event.content:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(event.content, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`end`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`flush`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` elif`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event.event `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"ToolCallStarted\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`> Calling `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`event.tool.tool_name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` elif`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event.event `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"RunCompleted\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`Tokens: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`event.metrics.total_tokens`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})})}),_jsx(Step,{title:`Install dependencies`,children:_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`pip`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`pip`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` definable`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`uv`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`uv`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` pip`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` definable`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`poetry`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`poetry`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` add`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` definable`})]}),`\n`]})})})]})}),_jsx(Step,{title:`Export your API key`,children:_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mac`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` OPENAI_API_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sk-`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`***`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Windows`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`setx`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` OPENAI_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` sk-`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`***`})]}),`\n`]})})})]})}),_jsxs(Step,{title:`Run`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`python`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` agent_streaming.py`})]}),`\n`]})})}),_jsx(_components.p,{children:`Tokens appear in your terminal as they are generated.`})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`async-streaming`,children:`Async Streaming`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`11`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`11`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` asyncio`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` definable.agent `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Agent`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`agent `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Agent(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gpt-4o\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`instructions`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"You are a helpful assistant.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` main`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`():`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` agent.arun_stream(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Explain quantum computing.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event.event `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"RunContent\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` and`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` event.content:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(event.content, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`end`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`flush`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`asyncio.run(main())`})}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Agent with Streaming","description":"Stream agent responses token by token in real time.","href":"/agents/usage/agent-with-streaming","hidden":false}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Async Streaming","slug":"async-streaming","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"definableaiprivatelimited","siteName":"Definable AI","title":"Agent with Streaming - Definable AI","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-02-25T20:56:01.804Z","originalFileLocation":"agents/usage/agent-with-streaming.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Stream agent responses token by token in real time.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Definable AI\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Agent with Streaming - Definable AI\">\u003cmeta data-mint-head property=\"og:description\" content=\"Stream agent responses token by token in real time.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Definable AI\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.definable.ai/agents/usage/agent-with-streaming\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://definableaiprivatelimited.mintlify.site/_mintlify/api/og/v2?division=Usage\u0026amp;title=Agent+with+Streaming\u0026amp;description=Stream+agent+responses+token+by+token+in+real+time.\u0026amp;theme=292dbdbb8f2a2bd1ee1ab5df\u0026amp;signature=96fab20858321e52f804578d545db45ed18450067b739d88a12de5218ca4fe8c\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Agent with Streaming - Definable AI\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Stream agent responses token by token in real time.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://definableaiprivatelimited.mintlify.site/_mintlify/api/og/v2?division=Usage\u0026amp;title=Agent+with+Streaming\u0026amp;description=Stream+agent+responses+token+by+token+in+real+time.\u0026amp;theme=292dbdbb8f2a2bd1ee1ab5df\u0026amp;signature=96fab20858321e52f804578d545db45ed18450067b739d88a12de5218ca4fe8c\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Definable AI\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#FA8112\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.definable.ai/agents/usage/agent-with-streaming\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/agents/usage/agent-with-streaming.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.definable.ai/#organization\",\"name\":\"Definable AI\",\"url\":\"https://docs.definable.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/definableaiprivatelimited/mDNvZulDI7LGheEl/logo/light.svg?fit=max\u0026auto=format\u0026n=mDNvZulDI7LGheEl\u0026q=85\u0026s=4b85977f6a03ffc7ceaa9b818e5d7990\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.definable.ai#website\",\"name\":\"Definable AI\",\"url\":\"https://docs.definable.ai\",\"publisher\":{\"@id\":\"https://docs.definable.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.definable.ai/agents/usage/agent-with-streaming#webpage\",\"url\":\"https://docs.definable.ai/agents/usage/agent-with-streaming\",\"name\":\"Agent with Streaming\",\"description\":\"Stream agent responses token by token in real time.\",\"dateModified\":\"2026-02-25T20:56:01.804Z\",\"isPartOf\":{\"@id\":\"https://docs.definable.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.definable.ai/agents/usage/agent-with-streaming#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.definable.ai/agents/usage/agent-with-streaming#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Basics\",\"item\":\"https://docs.definable.ai/agents/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Agents\",\"item\":\"https://docs.definable.ai/agents/overview\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Usage\",\"item\":\"https://docs.definable.ai/agents/usage/agent-with-tools\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Agent with Streaming\",\"item\":\"https://docs.definable.ai/agents/usage/agent-with-streaming\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.definable.ai/agents/usage/agent-with-streaming#article\",\"headline\":\"Agent with Streaming\",\"name\":\"Agent with Streaming\",\"description\":\"Stream agent responses token by token in real time.\",\"url\":\"https://docs.definable.ai/agents/usage/agent-with-streaming\",\"mainEntityOfPage\":{\"@id\":\"https://docs.definable.ai/agents/usage/agent-with-streaming#webpage\"},\"dateModified\":\"2026-02-25T20:56:01.804Z\",\"publisher\":{\"@id\":\"https://docs.definable.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.definable.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Definable AI\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Definable AI\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/agents/usage/agent-with-streaming.md","siteName":"Definable AI","nav":{"global":{"anchors":[{"anchor":"GitHub","icon":"github","href":"https://github.com/definable-ai/definable"},{"anchor":"PyPI","icon":"cube","href":"https://pypi.org/project/definable-ai/"}]},"tabs":[{"tab":"Documentation","groups":[{"group":"Get Started","pages":[{"title":"Definable","sidebarTitle":"Introduction","mode":"wide","href":"/introduction","hidden":false},{"title":"Your First Agent","mode":"wide","href":"/first-agent","hidden":false},{"title":"Quickstart","icon":"bolt","href":"/quickstart","hidden":false},{"title":"Installation","href":"/installation","hidden":false}]},{"group":"Basics","pages":[{"group":"Agents","pages":[{"title":"What are Agents?","sidebarTitle":"Overview","mode":"wide","href":"/agents/overview","hidden":false},{"title":"Building Agents","sidebarTitle":"Building Agents","mode":"wide","href":"/agents/building-agents","hidden":false},{"title":"Running Agents","sidebarTitle":"Running Agents","icon":"play","href":"/agents/running-agents","hidden":false},{"title":"Agent Configuration","sidebarTitle":"Configuration","icon":"gear","href":"/agents/configuration","hidden":false},{"group":"Usage","pages":[{"title":"Agent with Tools","href":"/agents/usage/agent-with-tools","hidden":false},{"title":"Agent with Knowledge","href":"/agents/usage/agent-with-knowledge","hidden":false},{"title":"Agent with Memory","href":"/agents/usage/agent-with-memory","hidden":false},{"title":"Agent with Structured Output","description":"Return typed Pydantic models from agent responses.","href":"/agents/usage/agent-with-structured-output","hidden":false},{"title":"Agent with Streaming","href":"/agents/usage/agent-with-streaming","hidden":false}]}]},{"group":"Teams","pages":[{"title":"What are Teams?","sidebarTitle":"Overview","description":"Teams coordinate multiple agents to collaborate, route, or divide work.","mode":"wide","href":"/teams/overview","hidden":false},{"title":"Building Teams","sidebarTitle":"Building Teams","mode":"wide","href":"/teams/building-teams","hidden":false},{"title":"Running Teams","sidebarTitle":"Running Teams","href":"/teams/running-teams","hidden":false},{"title":"Delegation","sidebarTitle":"Delegation","href":"/teams/delegation","hidden":false},{"group":"Usage","pages":[{"title":"Coordinate Team","href":"/teams/usage/coordinate-team","hidden":false},{"title":"Route Team","href":"/teams/usage/route-team","hidden":false},{"title":"Collaborate Team","href":"/teams/usage/collaborate-team","hidden":false},{"title":"Tasks Team","href":"/teams/usage/tasks-team","hidden":false}]}]},{"group":"Workflows","pages":[{"title":"What are Workflows?","sidebarTitle":"Overview","mode":"wide","href":"/workflows/overview","hidden":false},{"title":"Building Workflows","sidebarTitle":"Building Workflows","mode":"wide","href":"/workflows/building-workflows","hidden":false},{"title":"Running Workflows","sidebarTitle":"Running Workflows","href":"/workflows/running-workflows","hidden":false},{"group":"Patterns","pages":[{"title":"Sequential Workflow","sidebarTitle":"Sequential","href":"/workflows/patterns/sequential","hidden":false},{"title":"Parallel Workflow","sidebarTitle":"Parallel","href":"/workflows/patterns/parallel","hidden":false},{"title":"Conditional Workflow","sidebarTitle":"Conditional","href":"/workflows/patterns/conditional","hidden":false},{"title":"Loop Workflow","sidebarTitle":"Loop","href":"/workflows/patterns/loop","hidden":false},{"title":"Router Workflow","sidebarTitle":"Router","href":"/workflows/patterns/router","hidden":false}]},{"group":"Usage","pages":[{"title":"Basic Workflow","href":"/workflows/usage/basic-workflow","hidden":false},{"title":"Nested Workflows","href":"/workflows/usage/nested-workflows","hidden":false}]}]},{"group":"Input \u0026 Output","pages":[{"title":"Structured Output","sidebarTitle":"Structured Output","href":"/input-output/structured-output","hidden":false},{"title":"Streaming","sidebarTitle":"Streaming","href":"/input-output/streaming","hidden":false},{"title":"Multimodal Input","sidebarTitle":"Multimodal","href":"/input-output/multimodal","hidden":false}]},{"group":"Models","pages":[{"title":"What are Models?","sidebarTitle":"Overview","icon":"microchip","mode":"wide","href":"/models/overview","hidden":false},{"title":"Model as String","sidebarTitle":"String Shorthand","href":"/models/model-as-string","hidden":false},{"group":"Providers","pages":[{"title":"OpenAI","icon":"brain","href":"/models/openai","hidden":false},{"title":"Anthropic","href":"/models/anthropic","hidden":false},{"title":"Google Gemini","href":"/models/google","hidden":false},{"title":"DeepSeek","icon":"bolt","href":"/models/deepseek","hidden":false},{"title":"Mistral","href":"/models/mistral","hidden":false},{"title":"Moonshot","icon":"moon","href":"/models/moonshot","hidden":false},{"title":"xAI","icon":"magnifying-glass","href":"/models/xai","hidden":false},{"title":"Perplexity","href":"/models/perplexity","hidden":false},{"title":"Ollama","href":"/models/ollama","hidden":false},{"title":"OpenRouter","href":"/models/openrouter","hidden":false},{"title":"OpenAI-Like Providers","sidebarTitle":"OpenAI-Like","icon":"plug","href":"/models/openai-like","hidden":false}]},{"title":"Model Resilience","sidebarTitle":"Resilience","href":"/models/resilience","hidden":false},{"title":"Streaming","icon":"bars-staggered","href":"/models/streaming","hidden":false},{"title":"Structured Output","icon":"code","href":"/models/structured-output","hidden":false},{"title":"Vision \u0026 Audio","icon":"image","href":"/models/vision-and-audio","hidden":false},{"title":"Metrics \u0026 Pricing","icon":"chart-line","href":"/models/metrics-and-pricing","hidden":false}]}]},{"group":"Capabilities","pages":[{"group":"Tools","pages":[{"title":"What are Tools?","sidebarTitle":"Overview","mode":"wide","href":"/tools/overview","hidden":false},{"title":"Creating Tools","sidebarTitle":"Overview","href":"/tools/creating-tools/overview","hidden":false},{"title":"Tool Parameters","sidebarTitle":"Parameters","icon":"list","href":"/tools/creating-tools/parameters","hidden":false},{"title":"Tool Hooks","sidebarTitle":"Hooks","icon":"anchor","href":"/tools/creating-tools/hooks","hidden":false},{"title":"Tool Caching","sidebarTitle":"Caching","icon":"database","href":"/tools/creating-tools/caching","hidden":false},{"title":"Async Tools","sidebarTitle":"Async Tools","icon":"rotate","href":"/tools/creating-tools/async-tools","hidden":false},{"title":"Tool Dependencies","sidebarTitle":"Dependencies","icon":"puzzle-piece","href":"/tools/creating-tools/dependencies","hidden":false},{"group":"Toolkits","pages":[{"title":"Toolkits Overview","sidebarTitle":"Overview","icon":"toolbox","href":"/toolkits/overview","hidden":false},{"title":"KnowledgeToolkit","icon":"book","href":"/toolkits/knowledge-toolkit","hidden":false},{"title":"MCPToolkit","icon":"plug","href":"/toolkits/mcp-toolkit","hidden":false}]},{"group":"Built-in Skills","pages":[{"title":"Skills Overview","sidebarTitle":"Overview","icon":"puzzle-piece","href":"/skills/overview","hidden":false},{"title":"Built-in Skills","sidebarTitle":"Built-in Skills","icon":"toolbox","href":"/skills/built-in","hidden":false},{"title":"MacOS Skill","sidebarTitle":"MacOS","icon":"apple","href":"/skills/macos","hidden":false},{"title":"Skill Registry","sidebarTitle":"Skill Registry","icon":"book","href":"/skills/registry","hidden":false}]}]},{"group":"Knowledge \u0026 RAG","pages":[{"title":"Knowledge Overview","sidebarTitle":"Overview","icon":"book","href":"/knowledge/overview","hidden":false},{"title":"Documents","icon":"file-lines","href":"/knowledge/documents","hidden":false},{"title":"Agent Integration","sidebarTitle":"Agent Integration","icon":"robot","href":"/knowledge/agent-integration","hidden":false},{"title":"Hybrid Search \u0026 Scoring","sidebarTitle":"Hybrid Search","icon":"magnifying-glass-chart","href":"/knowledge/hybrid-search","hidden":false},{"group":"Pipeline","pages":[{"title":"Readers","icon":"file-import","href":"/knowledge/pipeline/readers","hidden":false},{"title":"Chunkers","icon":"scissors","href":"/knowledge/pipeline/chunkers","hidden":false},{"title":"Embedders","icon":"vector-square","href":"/knowledge/pipeline/embedders","hidden":false},{"title":"Rerankers","icon":"ranking-star","href":"/knowledge/pipeline/rerankers","hidden":false},{"title":"Vector Databases","sidebarTitle":"Vector Databases","icon":"database","href":"/knowledge/pipeline/vector-databases","hidden":false}]},{"group":"Usage","pages":[{"title":"Basic RAG","href":"/knowledge/usage/basic-rag","hidden":false},{"title":"Hybrid Search","href":"/knowledge/usage/hybrid-search-example","hidden":false}]}]},{"group":"Memory","pages":[{"title":"Memory Overview","sidebarTitle":"Overview","icon":"brain","href":"/memory/overview","hidden":false},{"title":"Memory Stores","sidebarTitle":"Stores","icon":"database","href":"/memory/stores","hidden":false},{"title":"Agent Integration","sidebarTitle":"Agent Integration","icon":"link","href":"/memory/agent-integration","hidden":false}]},{"group":"Reasoning","pages":[{"title":"Thinking","sidebarTitle":"Thinking","href":"/reasoning/thinking","hidden":false},{"title":"Deep Research","sidebarTitle":"Deep Research","href":"/reasoning/deep-research","hidden":false}]},{"group":"MCP","pages":[{"title":"MCP Overview","sidebarTitle":"Overview","icon":"plug","href":"/mcp/overview","hidden":false},{"title":"Getting Started with MCP","sidebarTitle":"Getting Started","icon":"rocket","href":"/mcp/getting-started","hidden":false},{"title":"MCP Configuration","sidebarTitle":"Configuration","icon":"gear","href":"/mcp/configuration","hidden":false},{"title":"MCP Resources","sidebarTitle":"Resources","icon":"folder-open","href":"/mcp/resources","hidden":false},{"title":"MCP Prompts","sidebarTitle":"Prompts","icon":"message","href":"/mcp/prompts","hidden":false},{"title":"MCP Error Handling","sidebarTitle":"Error Handling","icon":"triangle-exclamation","href":"/mcp/error-handling","hidden":false},{"title":"Mock MCP Servers","sidebarTitle":"Mock Servers","icon":"flask-vial","href":"/mcp/mock-servers","hidden":false}]},{"group":"Readers","pages":[{"title":"File Readers","sidebarTitle":"Overview","icon":"file-lines","href":"/readers/overview","hidden":false}]},{"group":"Browser","pages":[{"title":"Browser Toolkit","sidebarTitle":"Overview","icon":"globe","href":"/browser/overview","hidden":false}]},{"group":"Tracing","pages":[{"title":"Tracing","icon":"chart-gantt","href":"/agents/tracing","hidden":false}]},{"group":"Evaluation","pages":[{"title":"Evaluation","sidebarTitle":"Evaluation","icon":"chart-bar","href":"/agents/evaluation","hidden":false}]}]},{"group":"Advanced","pages":[{"group":"Interfaces","pages":[{"title":"Interfaces Overview","sidebarTitle":"Overview","icon":"message-bot","href":"/interfaces/overview","hidden":false},{"group":"Platforms","pages":[{"title":"Telegram","icon":"paper-plane","href":"/interfaces/telegram","hidden":false},{"title":"Discord","icon":"discord","href":"/interfaces/discord","hidden":false},{"title":"Slack","icon":"slack","href":"/interfaces/slack","hidden":false},{"title":"WebSocket","sidebarTitle":"WebSocket","href":"/interfaces/websocket","hidden":false},{"title":"WhatsApp","sidebarTitle":"WhatsApp","icon":"comment-dots","href":"/interfaces/whatsapp"},{"title":"Email","sidebarTitle":"Email","href":"/interfaces/email","hidden":false},{"title":"Call (Voice)","icon":"phone","href":"/interfaces/call","hidden":false},{"title":"Custom Interfaces","sidebarTitle":"Custom Interfaces","icon":"code","href":"/interfaces/custom-interfaces","hidden":false}]},{"group":"Usage","pages":[{"title":"Telegram Bot","href":"/interfaces/usage/telegram-bot","hidden":false},{"title":"Discord Bot","href":"/interfaces/usage/discord-bot","hidden":false},{"title":"Slack Bot","href":"/interfaces/usage/slack-bot","hidden":false},{"title":"Multi-Platform Agent","href":"/interfaces/usage/multi-platform","hidden":false}]},{"title":"Sessions","icon":"clock-rotate-left","href":"/interfaces/sessions","hidden":false},{"title":"Interface Hooks","sidebarTitle":"Hooks","icon":"anchor","href":"/interfaces/hooks","hidden":false},{"title":"Identity Resolution","sidebarTitle":"Identity","icon":"fingerprint","href":"/interfaces/identity","hidden":false},{"title":"Multi-Interface Serving","sidebarTitle":"Multi-Interface","icon":"server","href":"/interfaces/multi-interface","hidden":false}]},{"group":"Security","pages":[{"title":"Security","sidebarTitle":"Security","icon":"shield-halved","href":"/agents/security","hidden":false}]},{"group":"Guardrails","pages":[{"title":"Guardrails Overview","sidebarTitle":"Overview","icon":"shield","href":"/guardrails/overview","hidden":false}]},{"group":"Plugins","pages":[{"title":"Plugins","sidebarTitle":"Plugins","href":"/agents/plugins","hidden":false}]},{"group":"Scheduling","pages":[{"title":"Scheduling","sidebarTitle":"Scheduling","href":"/agents/scheduling","hidden":false}]},{"title":"Middleware","icon":"layer-group","href":"/agents/middleware","hidden":false},{"title":"Multi-Turn Conversations","sidebarTitle":"Multi-Turn","icon":"comments","href":"/agents/multi-turn","hidden":false},{"title":"Agentic Loop","sidebarTitle":"Agentic Loop","icon":"rotate","href":"/agents/agentic-loop","hidden":false},{"title":"Testing","icon":"flask-vial","href":"/agents/testing","hidden":false},{"title":"Authentication","sidebarTitle":"Authentication","icon":"lock","href":"/agents/auth","hidden":false},{"title":"Agent Runtime","sidebarTitle":"Runtime","icon":"server","href":"/agents/runtime","hidden":false},{"title":"Error Handling","icon":"shield","href":"/advanced/error-handling","hidden":false},{"title":"Cost Tracking","icon":"dollar-sign","href":"/advanced/cost-tracking","hidden":false},{"title":"Run Output \u0026 Events","sidebarTitle":"Run Output","icon":"square-poll-vertical","href":"/advanced/run-output","hidden":false},{"title":"Media Types","icon":"photo-film","href":"/advanced/media-types","hidden":false},{"title":"Replay Overview","sidebarTitle":"Overview","icon":"rotate","href":"/replay/overview","hidden":false},{"title":"Observability Dashboard","sidebarTitle":"Overview","icon":"chart-line","href":"/observability/overview","hidden":false},{"title":"Claude Code Agent","href":"/claude-code/overview","hidden":false}]}]},{"tab":"Examples","pages":[{"title":"Examples","href":"/examples/overview"}]},{"tab":"Reference","pages":[{"title":"Reference","href":"/reference/agents/agent"}]}]},"basePath":"","title":"Agent with Streaming - Definable AI","deploymentId":"dpl_BLZw3QngerHodH9E8mGgC4v752y3","buildId":"dpl_BLZw3QngerHodH9E8mGgC4v752y3","dynamics":[],"chunks":[]}