How to request streaming chat completions responses
Set stream: true to receive Server-Sent Events as chat.completion.chunk frames:
The first frame carries delta.role: "assistant" and the top-level citations[] extension.
Subsequent frames carry delta.content text deltas.
The terminal frame carries finish_reason.
The stream ends with data: [DONE].
import osfrom openai import OpenAIclient = OpenAI( base_url="https://api.seltz.ai/v1", api_key=os.environ["SELTZ_API_KEY"],)stream = client.chat.completions.create( model="seltz-base", messages=[{"role": "user", "content": "Who is going to be Apple's next CEO?"}], stream=True,)for chunk in stream: delta = chunk.choices[0].delta if delta.content: print(delta.content, end="")
import OpenAI from "openai";const client = new OpenAI({ baseURL: "https://api.seltz.ai/v1", apiKey: process.env.SELTZ_API_KEY,});const stream = await client.chat.completions.create({ model: "seltz-base", messages: [ { role: "user", content: "Who is going to be Apple's next CEO?" }, ], stream: true,});for await (const chunk of stream) { const delta = chunk.choices[0].delta; if (delta.content) { process.stdout.write(delta.content); }}
curl -N -X POST https://api.seltz.ai/v1/chat/completions \ -H "Authorization: Bearer $SELTZ_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "seltz-base", "messages": [ {"role": "user", "content": "Who is going to be Apple'\''s next CEO?"} ], "stream": true }'
Once stream: true is set, every error — including authentication and validation failures — is emitted as a single terminal frame, data: {"error":{...}}, under HTTP 200, with no trailing data: [DONE]. Do not branch on the HTTP status for streaming requests.The error frame carries no choices, so a hand-rolled parser doing chunk["choices"][0] gets a KeyError. A genuine mid-stream error is always api_error, and any text already emitted stays on the reader’s screen with no truncation marker.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Seltz","colors":{"primary":"#1CC19C","light":"#6BECCD","dark":"#1CC19C"},"logo":{"light":"https://mintcdn.com/seltz-5ef1e800/huLsbhQ2iI21xcNG/logo/light.svg?fit=max\u0026auto=format\u0026n=huLsbhQ2iI21xcNG\u0026q=85\u0026s=e22b03ca4a14b5db3456cb8d720d0571","dark":"https://mintcdn.com/seltz-5ef1e800/huLsbhQ2iI21xcNG/logo/dark.svg?fit=max\u0026auto=format\u0026n=huLsbhQ2iI21xcNG\u0026q=85\u0026s=553e741bced7b0801691e8d736d75459"},"favicon":"https://mintcdn.com/seltz-5ef1e800/huLsbhQ2iI21xcNG/favicon.svg?fit=max\u0026auto=format\u0026n=huLsbhQ2iI21xcNG\u0026q=85\u0026s=293a942921dbe302603a96265f1e3eb0","appearance":{"default":"light","strict":true},"navbar":{"links":[{"href":"mailto:[email protected]","label":"Support"}],"primary":{"type":"button","label":"Console","href":"https://console.seltz.ai/"}},"footer":{"socials":{"github":"https://github.com/seltz-ai","linkedin":"https://www.linkedin.com/company/seltz","x":"https://x.com/seltz_ai"}},"fonts":{"heading":{"family":"Space Grotesk","weight":600},"body":{"family":"Inter","weight":400}},"markdown":{"instructions":["Seltz is the web knowledge layer for AI agents: web search, cited answers, multi-step research, page fetching, and recurring monitors, served from Seltz's own index rather than a live scrape.","Use Seltz when a task needs current, citable, public web content, not when your own knowledge already answers it confidently. Seltz has no access to a caller's private or authenticated data.","Choose which endpoint to use according to the job: Use Answer for one synthesized, cited response; Use Search for the raw documents to reason over yourself; Use Agent for in-depth research needing several rounds of searching and following up, not a single lookup; Use Fetch when you already have a URL and just need its content, not a search; Use Monitor for an ongoing feed of what's new, not a one-off query or near-real-time alerting.","When you use Search, Answer, or Monitor, set a `scope` that matches the query. `web` (beta) is the default and covers general queries. Only these three endpoints take a scope. See https://docs.seltz.ai/data/data-concepts#scopes for the full list of scopes and what each one covers.","For the REST API, send your API key in the `x-api-key` header. The Python and JavaScript SDKs read the `SELTZ_API_KEY` environment variable and handle authentication for you. To use Seltz as MCP tools, connect `https://mcp.seltz.ai/mcp`.","The OpenAPI 3.1 spec for the REST API is at https://docs.seltz.ai/api-reference/openapi.json. Point function-calling or client-generation tooling at that file.","Use `/llms-full.txt` for the full text of every page."]},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"Playground","icon":"play","href":"https://console.seltz.ai/playground"},{"anchor":"About","icon":"info","href":"https://seltz.ai/about"},{"anchor":"Book a Call","icon":"calendar","href":"https://cal.com/antonio-mallia-c7uyfc/seltz-intro-call"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"seltz-5ef1e800","hasAudioNarration":false,"actualSubdomain":"seltz-5ef1e800","customDomains":["docs.seltz.ai"],"gitSource":{"type":"github","owner":"seltz-ai","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6aeb666f5102e32bf626169e","clientVersion":"0.0.4111","searchFilterCounts":[{"language":"default","tag":"Documentation","count":76},{"language":"default","tag":"Web Tools","count":36},{"language":"default","tag":"Guides","count":28},{"language":"default","tag":"Changelog","count":24},{"language":"default","tag":"REST API Reference","count":20},{"language":"default","tag":"Monitor","count":17},{"language":"default","tag":"Agent","count":13},{"language":"default","tag":"Integrations","count":11},{"language":"default","tag":"Search","count":11},{"language":"default","tag":"September 2026","count":8}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true,"deflection":{"enabled":true,"email":"[email protected]"}},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","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":"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":"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":"assistant-v5","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":"workos-sso-scim","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":"workos-signup","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":"workos-enabled","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":"sso-setup-deadline-banner","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}],"googleFontsInlined":true},"customCss":[{"filePath":"custom.css","content":":root{--primary: 28 193 156;--primary-light: 107 236 205;--primary-dark: 28 193 156;--background-light: 242 245 250;--background-dark: 13 17 25;--gray-50: 248 250 255;--gray-100: 242 245 250;--gray-200: 207 220 237;--gray-300: 176 190 210;--gray-400: 108 118 140;--gray-500: 87 98 124;--gray-600: 69 79 102;--gray-700: 45 59 91;--gray-800: 17 21 33;--gray-900: 13 17 25;--gray-950: 10 13 19}h1,h2,h3,h4,h5,h6{letter-spacing:-0.02em;font-weight:600}h1{font-size:2.25rem;line-height:1.2}h2{font-size:1.5rem;line-height:1.3}p,li{line-height:1.7;color:rgb(var(--gray-600))}a{transition:color 0.15s ease}[data-rehype-pretty-code-figure]{margin:1rem 0}[data-rehype-pretty-code-figure] pre{background:#FAFBFC!important;border:1px solid #E5E7EB!important;border-radius:12px!important;padding:1rem!important;overflow-x:auto}[data-rehype-pretty-code-figure] [data-rehype-pretty-code-title]{background:#F3F4F6!important;border:1px solid #E5E7EB!important;border-bottom:none!important;border-radius:12px 12px 0 0!important;padding:0.5rem 1rem!important;font-size:0.8rem!important;font-weight:500!important;color:#6B7280!important;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif!important}[data-rehype-pretty-code-figure] [data-rehype-pretty-code-title]+pre{border-top-left-radius:0!important;border-top-right-radius:0!important}[data-rehype-pretty-code-figure] code{font-family:'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Monaco, monospace!important;font-size:0.875rem!important;line-height:1.6!important;background:transparent!important}[data-rehype-pretty-code-figure] .line{padding:0 0.25rem}[data-rehype-pretty-code-figure] [style*=\"color:#CF222E\"],[data-rehype-pretty-code-figure] [style*=\"color:#cf222e\"]{color:#BE185D!important}[data-rehype-pretty-code-figure] [style*=\"color:#0A3069\"],[data-rehype-pretty-code-figure] [style*=\"color:#0a3069\"]{color:#0D9488!important}[data-rehype-pretty-code-figure] [style*=\"color:#8250DF\"],[data-rehype-pretty-code-figure] [style*=\"color:#8250df\"]{color:#7C3AED!important}[data-rehype-pretty-code-figure] [style*=\"color:#6E7781\"],[data-rehype-pretty-code-figure] [style*=\"color:#6e7781\"]{color:#9CA3AF!important;font-style:italic}[data-rehype-pretty-code-figure] [style*=\"color:#953800\"],[data-rehype-pretty-code-figure] [style*=\"color:#24292F\"],[data-rehype-pretty-code-figure] [style*=\"color:#24292f\"]{color:#374151!important}[data-rehype-pretty-code-figure] button[aria-label=\"Copy code\"]{background:rgba(28, 193, 156, 0.1)!important;border:1px solid rgba(28, 193, 156, 0.3)!important;border-radius:6px!important;color:#1CC19C!important;transition:all 0.15s ease!important}[data-rehype-pretty-code-figure] button[aria-label=\"Copy code\"]:hover{background:rgba(28, 193, 156, 0.2)!important;border-color:#1CC19C!important}:not(pre)>code{background:#F3F4F6!important;border:1px solid #E5E7EB!important;border-radius:6px!important;padding:0.125rem 0.375rem!important;font-size:0.875em!important;color:#BE185D!important;font-family:'SF Mono', 'Fira Code', Menlo, Monaco, monospace!important}code{font-family:'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Monaco, monospace;font-size:0.875em}.card{border-radius:12px;border:1px solid rgb(var(--gray-200));transition:box-shadow 0.2s ease, border-color 0.2s ease}.card:hover{border-color:rgb(var(--primary));box-shadow:0 4px 12px rgba(28, 193, 156, 0.1)}button,.button{border-radius:8px;font-weight:500;letter-spacing:-0.01em;transition:all 0.15s ease}nav{font-size:0.875rem}html{scroll-behavior:smooth}::selection{background:rgba(28, 193, 156, 0.2);color:rgb(var(--gray-900))}.mdx-content:has(>.not-prose:first-child){margin-top:0!important}"}],"page":{"pagePath":"chat-completions/guides/streaming","slug":"/chat-completions/guides/streaming","pageMetadata":{"title":"Streaming chat completions","description":"How to request streaming chat completions responses","href":"/chat-completions/guides/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: \"How to request streaming chat completions responses\"\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`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Set `,_jsx(_components.code,{children:`stream: true`}),` to receive Server-Sent Events as `,_jsx(_components.code,{children:`chat.completion.chunk`}),` frames:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`The `,_jsx(_components.strong,{children:`first`}),` frame carries `,_jsx(_components.code,{children:`delta.role: \"assistant\"`}),` and the top-level `,_jsx(_components.code,{children:`citations[]`}),` extension.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Subsequent`}),` frames carry `,_jsx(_components.code,{children:`delta.content`}),` text deltas.`]}),`\n`,_jsxs(_components.li,{children:[`The `,_jsx(_components.strong,{children:`terminal`}),` frame carries `,_jsx(_components.code,{children:`finish_reason`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`The stream ends with `,_jsx(_components.code,{children:`data: [DONE]`}),`.`]}),`\n`]}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Python`,numberOfLines:`19`,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:`19`,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:` os`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\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:` openai `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` base_url`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://api.seltz.ai/v1\"`}),_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:` api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`os.environ[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"SELTZ_API_KEY\"`}),_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`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`stream `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.chat.completions.create(`})]}),`\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:`\"seltz-base\"`}),_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:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Who is going to be Apple's next CEO?\"`}),_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:` stream`}),_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`,children:_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\":`#C586C0`},children:`for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` chunk `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` stream:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` delta `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` chunk.choices[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].delta`})]}),`\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:` delta.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:`(delta.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:`)`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`TypeScript`,numberOfLines:`21`,language:`typescript`,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:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`21`,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\":`#9CDCFE`},children:` OpenAI`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"openai\"`}),_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:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` client`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` OpenAI`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` baseURL:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"https://api.seltz.ai/v1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` apiKey:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` process`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`env`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`SELTZ_API_KEY`}),_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`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` stream`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` client`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`chat`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`completions`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`create`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` model:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"seltz-base\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` messages:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`role:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`content:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Who is going to be Apple's next CEO?\"`}),_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`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` stream:`}),_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`,children:_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\":`#C586C0`},children:`for`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` chunk`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` of`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` stream`}),_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\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` delta`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` chunk`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`choices`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`delta`}),_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:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`delta`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`content`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` process`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`stdout`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`write`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`delta`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`content`}),_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`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),_jsx(CodeBlock,{filename:`cURL`,numberOfLines:`10`,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:`10`,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:` -N`}),_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.seltz.ai/v1/chat/completions`}),_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 `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$SELTZ_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_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:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"model\": \"seltz-base\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"messages\": [`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` {\"role\": \"user\", \"content\": \"Who is going to be Apple'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\'`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'s next CEO?\"}`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ],`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"stream\": true`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }'`})}),`\n`]})})})]}),`\n`,_jsxs(Warning,{children:[_jsxs(_components.p,{children:[`Once `,_jsx(_components.code,{children:`stream: true`}),` is set, `,_jsx(_components.strong,{children:`every`}),` error — including authentication and validation failures — is emitted as a single terminal frame, `,_jsx(_components.code,{children:`data: {\"error\":{...}}`}),`, under `,_jsx(_components.strong,{children:`HTTP 200`}),`, with `,_jsx(_components.strong,{children:`no`}),` trailing `,_jsx(_components.code,{children:`data: [DONE]`}),`. Do not branch on the HTTP status for streaming requests.`]}),_jsxs(_components.p,{children:[`The error frame carries no `,_jsx(_components.code,{children:`choices`}),`, so a hand-rolled parser doing `,_jsx(_components.code,{children:`chunk[\"choices\"][0]`}),` gets a `,_jsx(_components.code,{children:`KeyError`}),`. A genuine mid-stream error is always `,_jsx(_components.code,{children:`api_error`}),`, and any text already emitted stays on the reader’s screen with no truncation marker.`]})]})]})}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 chat completions","description":"How to request streaming chat completions responses","href":"/chat-completions/guides/streaming"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":[],"subdomain":"seltz-5ef1e800","siteName":"Seltz","title":"Streaming chat completions - Seltz","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-25T17:50:48.198Z","originalFileLocation":"chat-completions/guides/streaming.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=\"light\";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=\"light\"}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=\"How to request streaming chat completions responses\">\u003cmeta data-mint-head name=\"application-name\" content=\"Seltz\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/seltz-5ef1e800/UnZxSzgmaFIilPTT/_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/seltz-5ef1e800/UnZxSzgmaFIilPTT/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/seltz-5ef1e800/UnZxSzgmaFIilPTT/_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/seltz-5ef1e800/UnZxSzgmaFIilPTT/_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/seltz-5ef1e800/UnZxSzgmaFIilPTT/_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/seltz-5ef1e800/UnZxSzgmaFIilPTT/_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/seltz-5ef1e800/UnZxSzgmaFIilPTT/_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/seltz-5ef1e800/UnZxSzgmaFIilPTT/_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/seltz-5ef1e800/UnZxSzgmaFIilPTT/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Streaming chat completions - Seltz\">\u003cmeta data-mint-head property=\"og:description\" content=\"How to request streaming chat completions responses\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Seltz\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.seltz.ai/chat-completions/guides/streaming\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://seltz-5ef1e800.mintlify.site/_mintlify/api/og/v2?division=Guides\u0026amp;title=Streaming+chat+completions\u0026amp;description=How+to+request+streaming+chat+completions+responses\u0026amp;theme=34d4b818f0139e9319c62155\u0026amp;signature=efbf36e49c4f88ca0bbd0e54b2e1be65de1ec6ba69388477cd23c0b4b8e581c7\">\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 chat completions - Seltz\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"How to request streaming chat completions responses\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://seltz-5ef1e800.mintlify.site/_mintlify/api/og/v2?division=Guides\u0026amp;title=Streaming+chat+completions\u0026amp;description=How+to+request+streaming+chat+completions+responses\u0026amp;theme=34d4b818f0139e9319c62155\u0026amp;signature=efbf36e49c4f88ca0bbd0e54b2e1be65de1ec6ba69388477cd23c0b4b8e581c7\">\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/seltz-5ef1e800/UnZxSzgmaFIilPTT/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Seltz\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#1CC19C\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.seltz.ai/chat-completions/guides/streaming\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/chat-completions/guides/streaming.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.seltz.ai/#organization\",\"name\":\"Seltz\",\"url\":\"https://docs.seltz.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/seltz-5ef1e800/huLsbhQ2iI21xcNG/logo/light.svg?fit=max\u0026auto=format\u0026n=huLsbhQ2iI21xcNG\u0026q=85\u0026s=e22b03ca4a14b5db3456cb8d720d0571\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.seltz.ai#website\",\"name\":\"Seltz\",\"url\":\"https://docs.seltz.ai\",\"publisher\":{\"@id\":\"https://docs.seltz.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.seltz.ai/chat-completions/guides/streaming#webpage\",\"url\":\"https://docs.seltz.ai/chat-completions/guides/streaming\",\"name\":\"Streaming chat completions\",\"description\":\"How to request streaming chat completions responses\",\"dateModified\":\"2026-09-25T17:50:48.198Z\",\"isPartOf\":{\"@id\":\"https://docs.seltz.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.seltz.ai/chat-completions/guides/streaming#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.seltz.ai/chat-completions/guides/streaming#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Chat\",\"item\":\"https://docs.seltz.ai/chat-completions/quickstart\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Chat completions\",\"item\":\"https://docs.seltz.ai/chat-completions/quickstart\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Guides\",\"item\":\"https://docs.seltz.ai/chat-completions/guides/authentication\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Streaming chat completions\",\"item\":\"https://docs.seltz.ai/chat-completions/guides/streaming\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.seltz.ai/chat-completions/guides/streaming#article\",\"headline\":\"Streaming chat completions\",\"name\":\"Streaming chat completions\",\"description\":\"How to request streaming chat completions responses\",\"url\":\"https://docs.seltz.ai/chat-completions/guides/streaming\",\"mainEntityOfPage\":{\"@id\":\"https://docs.seltz.ai/chat-completions/guides/streaming#webpage\"},\"dateModified\":\"2026-09-25T17:50:48.198Z\",\"publisher\":{\"@id\":\"https://docs.seltz.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.seltz.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Seltz\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Seltz\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/chat-completions/guides/streaming.md","siteName":"Seltz","nav":{"global":{"anchors":[{"anchor":"Playground","icon":"play","href":"https://console.seltz.ai/playground"},{"anchor":"About","icon":"info","href":"https://seltz.ai/about"},{"anchor":"Book a Call","icon":"calendar","href":"https://cal.com/antonio-mallia-c7uyfc/seltz-intro-call"}]},"tabs":[{"tab":"Documentation","groups":[{"group":"Getting Started","pages":[{"title":null,"sidebarTitle":"Introduction","mode":"wide","href":""},{"title":"Quickstart","href":"/quickstart"},{"title":"Pricing","href":"/pricing"}]},{"group":"Web Tools","pages":[{"group":"Search","expanded":false,"pages":[{"title":"Search concepts","sidebarTitle":"Concepts","href":"/search/search-concepts"},{"group":"Guides","pages":[{"title":"Basic search","href":"/search/guides/basic-search"},{"title":"Decrease search latency","href":"/search/guides/choose-a-tier"},{"title":"Limit results","href":"/search/guides/limit-results"},{"title":"Filter by date","href":"/search/filter-by-date"},{"title":"Process results","href":"/search/guides/process-results"},{"title":"Get snippets","href":"/search/guides/get-snippets"},{"title":"Get structured properties","href":"/search/guides/get-structured-properties"},{"title":"Control content length","href":"/search/guides/control-content-length"},{"title":"Handle errors","href":"/search/guides/handle-errors"}]},{"title":"Search reference","href":"/search/search-reference"}]},{"group":"Answer","expanded":false,"pages":[{"title":"Answer concepts","sidebarTitle":"Concepts","href":"/answer/answer-concepts"},{"group":"Guides","pages":[{"title":"Basic answer","href":"/answer/guides/basic-answer"},{"title":"Request a structured response","href":"/answer/guides/structured-response"},{"title":"Steer tone and style","href":"/answer/guides/system-prompt"}]},{"title":"Answer reference","href":"/answer/answer-reference"}]},{"group":"Monitor","expanded":false,"pages":[{"title":"Quickstart","href":"/monitor/quickstart"},{"title":"Concepts","href":"/monitor/concepts"},{"group":"Guides","pages":[{"title":"Read records","href":"/monitor/guides/read-records"},{"title":"Webhooks","href":"/monitor/guides/webhooks"},{"title":"Inspect runs","href":"/monitor/guides/inspect-runs"},{"title":"Manage monitors","href":"/monitor/guides/manage-monitors"}]},{"title":"Reference","href":"/monitor/reference"}]},{"group":"Fetch","expanded":false,"pages":[{"title":"Quickstart","href":"/fetch/quickstart"},{"title":"Concepts","href":"/fetch/concepts"},{"group":"Guides","pages":[{"title":"Handle errors","href":"/fetch/guides/handle-errors"}]},{"title":"Reference","href":"/fetch/reference"}]},{"group":"Agent","expanded":false,"pages":[{"title":"Quickstart","href":"/agent/quickstart"},{"title":"Concepts","href":"/agent/concepts"},{"group":"Guides","pages":[{"title":"Basic run","href":"/agent/guides/basic-run"},{"title":"Structured output","href":"/agent/guides/structured-output"},{"title":"List runs","href":"/agent/guides/list-runs"},{"title":"Poll for completion","href":"/agent/guides/poll-for-completion"},{"title":"Cancel a run","href":"/agent/guides/cancel-a-run"},{"title":"Handle errors","href":"/agent/guides/handle-errors"}]},{"title":"Reference","href":"/agent/reference"}]}]},{"group":"Data","pages":[{"title":"Data Concepts","sidebarTitle":"Concepts","href":"/data/data-concepts"},{"title":"Structured responses","href":"/data/structured-responses"},{"title":"Companies","href":"/data/companies"},{"title":"Financial reports","href":"/data/financial-reports"},{"title":"News","href":"/data/news"},{"title":"People","href":"/data/people"},{"title":"Web","tag":"Beta","href":"/data/web"},{"title":"Wikipedia","href":"/data/wikipedia"}]},{"group":"Tutorials","pages":[{"title":"Enrich a lead or company record using structured outputs","href":"/tutorials/enrich-record"},{"title":"Monitor a company list for M\u0026A deals using structured outputs","href":"/tutorials/monitor-ma-deals"},{"title":"Find lookalike candidates using seed and expand","href":"/tutorials/lookalike-candidates"}]},{"group":"Chat","pages":[{"group":"Chat completions","pages":[{"title":"Quickstart","href":"/chat-completions/quickstart"},{"title":"Concepts","href":"/chat-completions/concepts"},{"group":"Guides","pages":[{"title":"Authentication","href":"/chat-completions/guides/authentication"},{"title":"Citations","description":"Requesting citations in chat completions","href":"/chat-completions/guides/citations"},{"title":"Streaming chat completions","href":"/chat-completions/guides/streaming"},{"title":"Requesting structured chat completions outputs","description":"How to request structured outputs from the chat completions endpoint","href":"/chat-completions/guides/structured-outputs"},{"title":"Steer tone and format of chat completions","href":"/chat-completions/guides/steer-tone-and-format"}]},{"title":"Reference","href":"/chat-completions/reference"}]}]},{"group":"Integrations","pages":[{"group":"AI Platforms","expanded":false,"pages":[{"title":"MCP Server","href":"/integrations/mcp"},{"title":"Anthropic Tool Calling","href":"/integrations/anthropic-tool-calling"},{"title":"OpenAI Tool Calling","href":"/integrations/openai-tool-calling"},{"title":"Mistral Tool Calling","href":"/integrations/mistral-tool-calling"}]},{"group":"Workflow Automation","expanded":false,"pages":[{"title":"Zapier","href":"/integrations/zapier"},{"title":"viaSocket","href":"/integrations/viasocket"},{"title":"n8n","href":"/integrations/n8n"},{"title":"Dify","href":"/integrations/dify"}]},{"group":"Frameworks and Agents","expanded":false,"pages":[{"title":"Agno","href":"/integrations/agno"},{"title":"Langroid","href":"/integrations/langroid"},{"title":"LlamaIndex","href":"/integrations/llamaindex"}]}]},{"group":"SDKs","pages":[{"group":"Python SDK","expanded":false,"pages":[{"title":"Installation","href":"/sdks/python/installation"},{"title":"Quickstart","href":"/sdks/python/quickstart"},{"title":"Client Reference","href":"/sdks/python/client"}]},{"group":"JavaScript / TypeScript SDK","expanded":false,"pages":[{"title":"Installation","href":"/sdks/javascript/installation"},{"title":"Quickstart","href":"/sdks/javascript/quickstart"},{"title":"Client Reference","href":"/sdks/javascript/client"}]},{"group":"REST","expanded":false,"pages":[{"title":"cURL","href":"/sdks/rest/curl"}]}]}]},{"tab":"REST API Reference","pages":[{"title":"REST API Reference","href":"/api-reference/introduction"}]},{"tab":"Changelog","pages":[{"title":"Changelog","href":"/changelog/2026-10-search-properties"}]}]},"basePath":"","title":"Streaming chat completions - Seltz","buildId":"dpl_DqYu5MPb49gWBBbUGgpHQUmCHY3P","deploymentId":"dpl_DqYu5MPb49gWBBbUGgpHQUmCHY3P","dynamics":[],"chunks":[]}