Stream live model output from a Cerebrium endpoint over server-sent events by yielding results from a Python generator or iterator function.
Streaming sends live output from a model over a server-sent event (SSE) stream.
It works with any Python object that implements the iterator or generator protocol.The generator/iterator must yield data, which is sent downstream via the text/event-stream Content-Type.
You can send data in JSON format and decode it on the client side.A minimal example:
import timedef run(upper_range: int): for i in range(upper_range): yield f"Number {i} " time.sleep(1)
Deploy this snippet and call the endpoint. SSE events appear progressively, one per second:
HTTP/1.1 200 OKcache-control: no-cachecontent-encoding: gzipcontent-type: text/event-stream; charset=utf-8date: Tue, 28 May 2024 21:12:46 GMTserver: envoytransfer-encoding: chunkedvary: Accept-Encodingx-envoy-upstream-service-time: 198995x-request-id: e6b55132-32af-96d7-a064-8915c4a42452data: Number 0...
The remaining data streams in every second:
...data: Number 1data: Number 2
Postman also supports SSE streams natively.For a Falcon-7B streaming example, see the streaming endpoint example.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Cerebrium","description":"Cerebrium developer documentation for real-time and production AI workloads. Learn how to deploy low-latency inference APIs, voice agents, multi-region apps, serverless GPUs and CPUs, and workloads that need strong cold-start and scaling performance.","colors":{"primary":"#EB3A6F","light":"#F393B0","dark":"#C9134A"},"logo":{"light":"https://mintcdn.com/cerebrium/NdVkuYyL2KATsjiJ/logo/light.svg?fit=max\u0026auto=format\u0026n=NdVkuYyL2KATsjiJ\u0026q=85\u0026s=8e3656818ad3a5c3d278341b737e4df5","dark":"https://mintcdn.com/cerebrium/NdVkuYyL2KATsjiJ/logo/dark.svg?fit=max\u0026auto=format\u0026n=NdVkuYyL2KATsjiJ\u0026q=85\u0026s=f3195c190a7428f563168a6500f252ac","href":"https://cerebrium.ai"},"favicon":{"light":"https://mintcdn.com/cerebrium/w6QrtZunT-SzaBze/favicon.png?fit=max\u0026auto=format\u0026n=w6QrtZunT-SzaBze\u0026q=85\u0026s=aa12bb6b79cfb32c2b2b45e5d46ffe4d","dark":"https://mintcdn.com/cerebrium/w6QrtZunT-SzaBze/favicon.png?fit=max\u0026auto=format\u0026n=w6QrtZunT-SzaBze\u0026q=85\u0026s=aa12bb6b79cfb32c2b2b45e5d46ffe4d"},"background":{"image":"https://mintcdn.com/cerebrium/w6QrtZunT-SzaBze/images/background.png?fit=max\u0026auto=format\u0026n=w6QrtZunT-SzaBze\u0026q=85\u0026s=64228c5d68dbe6609311d5d6a0b48773","color":{"dark":"#121212"}},"navbar":{"links":[{"href":"mailto:support@cerebrium.ai","label":"Contact Us"}],"primary":{"type":"button","label":"Sign Up","href":"https://dashboard.cerebrium.ai/login"}},"footer":{"socials":{"twitter":"https://twitter.com/cerebriumai","discord":"https://discord.gg/ATj6USmeE2","linkedin":"https://www.linkedin.com/company/cerebriumai","github":"https://www.linkedin.com/company/cerebrium"}},"search":{"prompt":"Search Cerebrium docs..."},"seo":{"metatags":{"description":"Cerebrium developer documentation for real-time and production AI workloads. Learn how to deploy low-latency inference APIs, voice agents, multi-region apps, serverless GPUs and CPUs, and workloads that need strong cold-start and scaling performance.","keywords":"Cerebrium, serverless GPUs, AI infrastructure, hosting Large Language Models, AI voice agents, Real-time AI","language":"en","copyright":"Copyright 2025"},"indexing":"navigable"},"integrations":{"ga4":{"measurementId":"G-7SBXER6DHL"},"hotjar":{"hjid":"3423876","hjsv":"6"}},"contextual":{"options":["copy","view","download-spec","assistant","mcp","add-mcp","cursor","vscode","chatgpt","claude","perplexity"],"display":"header"},"markdown":{"instructions":"Cerebrium's documentation MCP server is available at https://cerebrium.ai/docs/mcp for searching and querying these docs directly. Install the Cerebrium agent skill with `npx skills add https://cerebrium.ai/docs`. Append .md to any docs page URL to fetch that page as plain Markdown. API keys and authentication tokens are created in the Cerebrium dashboard at https://dashboard.cerebrium.ai."},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"Dashboard","icon":"circle-play","href":"https://dashboard.cerebrium.ai/login"},{"anchor":"Blog","icon":"newspaper","href":"https://cerebrium.ai/blog"},{"anchor":"Community","icon":"discord","href":"https://discord.gg/ATj6USmeE2"},{"anchor":"Status","icon":"eye","href":"https://status.cerebrium.ai"},{"anchor":"Pricing","icon":"money-bill","href":"https://www.cerebrium.ai/pricing"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"cerebrium","hasAudioNarration":false,"actualSubdomain":"cerebrium","customDomains":["cerebrium.ai"],"gitSource":{"type":"github","owner":"cerebriumai","repo":"documentation","deployBranch":"master","contentDirectory":"","mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6abbd877d0c82aa0ccb97495","collectionId":"bb6cfcb5-3f4e-45e4-aa58-1dee0af23a5b","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6abbd877d0c82aa0ccb97495"},"feedback":{"thumbs":false},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6abbd877d0c82aa0ccb97495","clientVersion":"0.0.3965","searchFilterCounts":[{"language":"default","tag":"API Reference","count":94},{"language":"default","tag":"Documentation","count":34},{"language":"default","tag":"Examples","count":30},{"language":"default","tag":"Apps","count":12},{"language":"default","tag":"Integrations","count":10},{"language":"default","tag":"Builds","count":10},{"language":"default","tag":"Containers","count":9},{"language":"default","tag":"Custom Domains","count":7},{"language":"default","tag":"Endpoints","count":6},{"language":"default","tag":"Migrations","count":6}]},"assistantConfig":{"deflection":{"enabled":true,"email":"support@cerebrium.ai"}},"hasChatPermissions":true,"hasWebMcpPermissions":true,"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":"editor-v7-file-tree","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":"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":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"pause-universal-search-reconcile","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":"per-site-search-delta","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":"editor-private-page-search","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":"editor-nav-generations","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":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","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":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-agent-model-picker","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","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}],"isAtlas":false,"googleFontsInlined":false},"customCss":[{"filePath":"custom.css","content":"ul#sidebar-group>li>button.group{font-weight:700!important}"}],"page":{"pagePath":"endpoints/streaming","slug":"/endpoints/streaming","pageMetadata":{"title":"Streaming Endpoints","description":"Stream live model output from a Cerebrium endpoint over server-sent events by yielding results from a Python generator or iterator function.","href":"/endpoints/streaming"},"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 live model output from a Cerebrium endpoint over server-sent events by yielding results from a Python generator or iterator function.\"\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={a:`a`,code:`code`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock,OptimizedImage}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Streaming sends live output from a model over a server-sent event (SSE) stream.\nIt works with any Python object that implements the iterator or generator protocol.`}),`\n`,_jsxs(_components.p,{children:[`The generator/iterator must `,_jsx(_components.code,{children:`yield`}),` data, which is sent downstream via the `,_jsx(_components.code,{children:`text/event-stream`}),` Content-Type.\nYou can send data in JSON format and decode it on the client side.`]}),`\n`,_jsx(_components.p,{children:`A minimal example:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,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:`6`,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:` time`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`upper_range`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`int`}),_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:` for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` i `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` range`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(upper_range):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` yield`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Number `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`i`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` time.sleep(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Deploy this snippet and call the endpoint. SSE events appear progressively, one per second:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,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:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'https://api.cerebrium.ai/v4/p-xxxxxxxx/2-streaming-endpoint/run'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Content-Type: application/json'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Accept: text/event-stream'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Authorization: Bearer \u003cYOUR-JWT-TOKEN>'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --data`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"upper_range\": 3}'`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`This should output:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`13`,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:`13`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`HTTP/1.1`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 200`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` OK`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`cache-control:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` no-cache`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`content-encoding:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` gzip`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`content-type:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` text/event-stream`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`charset`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`utf-8`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`date:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` Tue,`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 28`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` May`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 2024`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 21:12:46`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` GMT`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`server:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` envoy`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`transfer-encoding:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` chunked`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`vary:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` Accept-Encoding`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`x-envoy-upstream-service-time:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 198995`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`x-request-id:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` e6b55132-32af-96d7-a064-8915c4a42452`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`data:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` Number`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`...`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`The remaining data streams in every second:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`5`,language:`text`,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:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`...`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`data: Number 1`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`data: Number 2`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Postman also supports SSE streams natively.`}),`\n`,_jsx(OptimizedImage,{src:`https://mintcdn.com/cerebrium/w6QrtZunT-SzaBze/images/cortex/streaming-postman.png?fit=max\u0026auto=format\u0026n=w6QrtZunT-SzaBze\u0026q=85\u0026s=8718df1936d620d2c7be03b5d9edb0a4`,alt:`Streaming`,\"data-og-width\":`2600`,width:`2600`,\"data-og-height\":`1668`,height:`1668`,\"data-path\":`images/cortex/streaming-postman.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/cerebrium/w6QrtZunT-SzaBze/images/cortex/streaming-postman.png?w=280\u0026fit=max\u0026auto=format\u0026n=w6QrtZunT-SzaBze\u0026q=85\u0026s=1d640fb5355ce901766d809c5385923e 280w, https://mintcdn.com/cerebrium/w6QrtZunT-SzaBze/images/cortex/streaming-postman.png?w=560\u0026fit=max\u0026auto=format\u0026n=w6QrtZunT-SzaBze\u0026q=85\u0026s=730253af975656d069849a1a0a80e579 560w, https://mintcdn.com/cerebrium/w6QrtZunT-SzaBze/images/cortex/streaming-postman.png?w=840\u0026fit=max\u0026auto=format\u0026n=w6QrtZunT-SzaBze\u0026q=85\u0026s=a7da7bfebe607089148df8abd5149041 840w, https://mintcdn.com/cerebrium/w6QrtZunT-SzaBze/images/cortex/streaming-postman.png?w=1100\u0026fit=max\u0026auto=format\u0026n=w6QrtZunT-SzaBze\u0026q=85\u0026s=be4c79d2dd65d2a1945f15ec3bd2c45b 1100w, https://mintcdn.com/cerebrium/w6QrtZunT-SzaBze/images/cortex/streaming-postman.png?w=1650\u0026fit=max\u0026auto=format\u0026n=w6QrtZunT-SzaBze\u0026q=85\u0026s=7b95ae2f7030feedcbbb7307d89a193e 1650w, https://mintcdn.com/cerebrium/w6QrtZunT-SzaBze/images/cortex/streaming-postman.png?w=2500\u0026fit=max\u0026auto=format\u0026n=w6QrtZunT-SzaBze\u0026q=85\u0026s=9528c047c90115074335942f4f5e29f3 2500w`}),`\n`,_jsxs(_components.p,{children:[`For a Falcon-7B streaming example, see the `,_jsx(_components.a,{href:`https://github.com/CerebriumAI/examples/tree/master/5-large-language-models/2-streaming-endpoint`,children:`streaming endpoint example`}),`.`]})]})}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":"Streaming Endpoints","description":"Stream live model output from a Cerebrium endpoint over server-sent events by yielding results from a Python generator or iterator function.","href":"/endpoints/streaming"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":[],"subdomain":"cerebrium","siteName":"Cerebrium","title":"Streaming Endpoints - Cerebrium","navMaps":{"firstHrefInVersion":{"v4":{"href":"/endpoints/streaming","matchLevel":0}},"firstHrefInLanguage":{}},"lastModified":"2026-08-31T18:06:43.485Z","originalFileLocation":"endpoints/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 live model output from a Cerebrium endpoint over server-sent events by yielding results from a Python generator or iterator function.\">\u003cmeta data-mint-head name=\"keywords\" content=\"Cerebrium, serverless GPUs, AI infrastructure, hosting Large Language Models, AI voice agents, Real-time AI\">\u003cmeta data-mint-head name=\"application-name\" content=\"Cerebrium\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/cerebrium/IJlnpfXae_gDMbUq/_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=\"/docs/mintlify-assets/_mintlify/favicons/cerebrium/IJlnpfXae_gDMbUq/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/cerebrium/IJlnpfXae_gDMbUq/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/cerebrium/IJlnpfXae_gDMbUq/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/cerebrium/IJlnpfXae_gDMbUq/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/cerebrium/IJlnpfXae_gDMbUq/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/cerebrium/IJlnpfXae_gDMbUq/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/cerebrium/IJlnpfXae_gDMbUq/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/cerebrium/IJlnpfXae_gDMbUq/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Streaming Endpoints - Cerebrium\">\u003cmeta data-mint-head property=\"og:description\" content=\"Stream live model output from a Cerebrium endpoint over server-sent events by yielding results from a Python generator or iterator function.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Cerebrium\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://cerebrium.ai/docs/endpoints/streaming\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://cerebrium.mintlify.app/_mintlify/api/og/v2?division=Endpoints\u0026amp;title=Streaming+Endpoints\u0026amp;description=Stream+live+model+output+from+a+Cerebrium+endpoint+over+server-sent+events+by+yielding+results+from+a+Python+generator+or+iterator+function.\u0026amp;theme=b856aa40d2e6249cbf37eb38\u0026amp;signature=57fbc3f45919b24047d14a288a5495291465b604c9d2780b867da90c276c80ca\">\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=\"Streaming Endpoints - Cerebrium\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Stream live model output from a Cerebrium endpoint over server-sent events by yielding results from a Python generator or iterator function.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://cerebrium.mintlify.app/_mintlify/api/og/v2?division=Endpoints\u0026amp;title=Streaming+Endpoints\u0026amp;description=Stream+live+model+output+from+a+Cerebrium+endpoint+over+server-sent+events+by+yielding+results+from+a+Python+generator+or+iterator+function.\u0026amp;theme=b856aa40d2e6249cbf37eb38\u0026amp;signature=57fbc3f45919b24047d14a288a5495291465b604c9d2780b867da90c276c80ca\">\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=\"/docs/mintlify-assets/_mintlify/favicons/cerebrium/IJlnpfXae_gDMbUq/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Cerebrium\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#EB3A6F\">\u003cmeta data-mint-head name=\"language\" content=\"en\">\u003cmeta data-mint-head name=\"copyright\" content=\"Copyright 2025\">\u003clink data-mint-head rel=\"canonical\" href=\"https://cerebrium.ai/docs/endpoints/streaming\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/endpoints/streaming.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://cerebrium.ai/#organization\",\"name\":\"Cerebrium\",\"url\":\"https://cerebrium.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/cerebrium/NdVkuYyL2KATsjiJ/logo/light.svg?fit=max\u0026auto=format\u0026n=NdVkuYyL2KATsjiJ\u0026q=85\u0026s=8e3656818ad3a5c3d278341b737e4df5\"}},{\"@type\":\"WebSite\",\"@id\":\"https://cerebrium.ai/docs#website\",\"name\":\"Cerebrium\",\"url\":\"https://cerebrium.ai/docs\",\"publisher\":{\"@id\":\"https://cerebrium.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://cerebrium.ai/docs/endpoints/streaming#webpage\",\"url\":\"https://cerebrium.ai/docs/endpoints/streaming\",\"name\":\"Streaming Endpoints\",\"description\":\"Stream live model output from a Cerebrium endpoint over server-sent events by yielding results from a Python generator or iterator function.\",\"dateModified\":\"2026-08-31T18:06:43.485Z\",\"isPartOf\":{\"@id\":\"https://cerebrium.ai/docs#website\"},\"breadcrumb\":{\"@id\":\"https://cerebrium.ai/docs/endpoints/streaming#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://cerebrium.ai/docs/endpoints/streaming#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Endpoints\",\"item\":\"https://cerebrium.ai/docs/endpoints/inference-api\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Streaming Endpoints\",\"item\":\"https://cerebrium.ai/docs/endpoints/streaming\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://cerebrium.ai/docs/endpoints/streaming#article\",\"headline\":\"Streaming Endpoints\",\"name\":\"Streaming Endpoints\",\"description\":\"Stream live model output from a Cerebrium endpoint over server-sent events by yielding results from a Python generator or iterator function.\",\"url\":\"https://cerebrium.ai/docs/endpoints/streaming\",\"mainEntityOfPage\":{\"@id\":\"https://cerebrium.ai/docs/endpoints/streaming#webpage\"},\"dateModified\":\"2026-08-31T18:06:43.485Z\",\"publisher\":{\"@id\":\"https://cerebrium.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://cerebrium.ai/docs#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Cerebrium\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Cerebrium","nav":{"global":{"anchors":[{"anchor":"Dashboard","icon":"circle-play","href":"https://dashboard.cerebrium.ai/login"},{"anchor":"Blog","icon":"newspaper","href":"https://cerebrium.ai/blog"},{"anchor":"Community","icon":"discord","href":"https://discord.gg/ATj6USmeE2"},{"anchor":"Status","icon":"eye","href":"https://status.cerebrium.ai"},{"anchor":"Pricing","icon":"money-bill","href":"https://www.cerebrium.ai/pricing"}]},"versions":[{"version":"v4","tabs":[{"tab":"Documentation","groups":[{"group":"Getting Started","pages":[{"title":"Introduction to Cerebrium for real-time AI workloads","href":"/getting-started/introduction"}]},{"group":"Container Images","pages":[{"title":"Defining Container Images","href":"/container-images/defining-container-images"},{"title":"Custom Python Web Servers","href":"/container-images/custom-web-servers"},{"title":"Custom Dockerfiles","href":"/container-images/custom-dockerfiles"},{"title":"Using Private Docker Registries","href":"/container-images/private-docker-registry"}]},{"group":"GPUs and Compute Resources","pages":[{"title":"Using GPUs","href":"/hardware/using-gpus"},{"title":"Using CUDA","href":"/hardware/using-cuda"},{"title":"CPU and Memory","href":"/hardware/cpu-and-memory"}]},{"group":"Performance","pages":[{"title":"Faster Cold Start Performance","href":"/performance/faster-cold-starts"},{"title":"Memory and GPU Checkpointing (Beta)","href":"/performance/checkpointing"}]},{"group":"Scaling apps","pages":[{"title":"Autoscaling apps on Cerebrium","href":"/scaling/scaling-apps"},{"title":"Preemption and Graceful Termination","href":"/scaling/graceful-termination"},{"title":"Batching and Concurrency","href":"/scaling/batching-concurrency"}]},{"group":"Deployments","pages":[{"title":"CI/CD Pipelines","href":"/deployments/ci-cd"},{"title":"Gradual Roll-out","href":"/deployments/gradual-roll-out"},{"title":"Multi-Region Deployment","href":"/deployments/multi-region-deployment"}]},{"group":"Endpoints","pages":[{"title":"REST API","description":"Call your Cerebrium apps over the REST API with POST requests and JWT authentication, and understand response formats and HTTP status codes.","href":"/endpoints/inference-api"},{"title":"Streaming Endpoints","href":"/endpoints/streaming"},{"title":"WebSocket Endpoints","description":"Create real-time bidirectional WebSocket endpoints on Cerebrium using a custom runtime with FastAPI and connect clients over secure wss URLs.","href":"/endpoints/websockets"},{"title":"Webhook Forwarding","href":"/endpoints/webhook"},{"title":"Async requests","href":"/endpoints/async"},{"title":"OpenAI-Compatible Endpoints","href":"/endpoints/openai-compatible-endpoints"}]},{"group":"Networking","pages":[{"title":"Custom Domains","href":"/networking/custom-domains"},{"title":"Inter-cluster routing","href":"/networking/inter-cluster-routing"}]},{"group":"Storage","pages":[{"title":"Managing Files","href":"/storage/managing-files"}]},{"group":"Partner Services","tag":"Beta","pages":[{"title":"Partner Services on Cerebrium with Deepgram and Rime","href":"/partner-services/index"},{"title":"Self-hosted Deepgram speech-to-text on Cerebrium","href":"/partner-services/deepgram"},{"title":"Rime","href":"/partner-services/rime"}]},{"group":"Integrations","pages":[{"title":"Exporting Metrics to Monitoring Platforms","href":"/integrations/metrics-export"}]},{"group":"Other concepts","pages":[{"title":"Security \u0026 Data Privacy","href":"/security"},{"title":"Using Secrets","href":"/other-topics/using-secrets"},{"title":"Request and Response Logging","href":"/other-topics/request-response-logging"},{"title":"Audit Log","href":"/other-topics/audit-log"},{"title":"Calculating compute cost","href":"/calculating-cost"}]}]},{"tab":"Examples","pages":[{"title":"Examples","href":"/v4/examples/featured"}]},{"tab":"Migrations","pages":[{"title":"Migrations","href":"/migrations/replicate"}]},{"tab":"TOML Reference","pages":[{"title":"TOML Reference","href":"/toml-reference/toml-reference"}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/api-reference/builds/health-check"}]}]}]},"title":"Streaming Endpoints - Cerebrium","buildId":"dpl_BvXubCjoPYfvfFiCP5WgKvGYUZ9k","deploymentId":"dpl_BvXubCjoPYfvfFiCP5WgKvGYUZ9k","dynamics":["a74be98ba7"],"chunks":["zoom-image-lightbox-kIzybAsE.js","lightbox-handle-r17bVUz3.js"]}