The Rime API authenticates every request with a bearer token in the Authorization header: Authorization: Bearer YOUR_API_KEY. See API authentication for how to create a key.
This page describes the legacy /ws endpoint, which keeps working for existing integrations. For a new Mist v3 integration, use Mist v3 WebSocket v1.
Overview
This WebSocket accepts plain text and returns raw audio bytes in the format you set with audioFormat. You pass every synthesis parameter as a query parameter when you open the connection, and those settings apply for the life of the connection.The API buffers input until it detects a sentence boundary, typically at ., ?, or !, so synthesis starts once it has enough text for natural prosody. The wait is most noticeable on the first sentence. After that, later text usually arrives while earlier audio is still playing, and the buffering becomes largely invisible. To change when synthesis starts, set segment.
Messages
Send
Send bare text, not JSON.
This will be converted to audio via websockets
Receive
Your client receives raw audio bytes in the audioFormat set at connection time. Append the messages in order to rebuild the audio. With pcm, a message can end mid-sample, so keep whole samples.
Commands
Send these strings as text messages to control the buffer.
<CLEAR>
Discards buffered text that hasn’t been synthesized yet. Send it when the user interrupts. It doesn’t cancel a synthesis already in progress, so stop playback in your client and drop any audio that still arrives.
<FLUSH>
Synthesizes whatever text is buffered, without waiting for a sentence boundary, and sends the audio.
<EOS>
Synthesizes whatever text is buffered, sends the audio, and then the server closes the connection.
One of wav, mp3 (or mpeg), ogg (Opus in OGG), webm (Opus in WebM), pcm (or l16), or mulaw (or pcmu). Unrecognized values fall back to wav.
string
default:"eng"
If provided, the language must match the language spoken by the selected speaker. Verify the pairing in the Rime voice catalog.
bool
default:"false"
When set to true, adds pauses between words enclosed in angle brackets. The number inside the brackets specifies the pause duration in milliseconds.
Example: Hi. <200> I'd love to have a conversation with you. adds a 200ms pause. Learn more about custom pauses.
int
The sampling rate in Hz. Default: 24000. Values above 24000 are upsampled.
string
Comma-separated list of speed values applied to words in square brackets. Values < 1.0 speed up speech, > 1.0 slow it down.
Example: “This is [slow] and [fast]”, use “3, 0.5” to make “slow” slower and “fast” faster.
float
default:"1.0"
Adjusts the speed of speech. Higher than 1.0 is faster and lower than 1.0 is slower.
string
default:"bySentence"
Controls how text is segmented for synthesis. Available options:
“immediate” - Synthesizes text immediately without waiting for complete sentences
“never” - Never segments the text, waits for explicit flush or EOS
“bySentence” (default) - Waits for complete sentences before synthesis
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Rime Docs","colors":{"primary":"#1DADC7","light":"#4FC3D9","dark":"#147D91"},"logo":{"light":"https://mintcdn.com/rimelabs/qBNCx7nLDEv-FtZq/logo/light.png?fit=max\u0026auto=format\u0026n=qBNCx7nLDEv-FtZq\u0026q=85\u0026s=b74ee12f1a1075334db19359152c2f8a","dark":"https://mintcdn.com/rimelabs/qBNCx7nLDEv-FtZq/logo/dark.png?fit=max\u0026auto=format\u0026n=qBNCx7nLDEv-FtZq\u0026q=85\u0026s=d13aea3ecd100ed7ca31c828e93b123f","href":"/"},"favicon":"https://mintcdn.com/rimelabs/Z6D4LmkrIeBeHoml/rime-social-logo.png?fit=max\u0026auto=format\u0026n=Z6D4LmkrIeBeHoml\u0026q=85\u0026s=41aa58d6143a74b8c11b8d9713e77344","api":{"playground":{"display":"none"}},"background":{"color":{"light":"#F0E9DD","dark":"#2E2A25"}},"navbar":{"links":[{"href":"https://www.rimestat.us","label":"Status"}],"primary":{"type":"button","label":"Dashboard","href":"https://app.rime.ai"}},"footer":{"links":[{"header":"Rime","items":[{"label":"Status","href":"https://www.rimestat.us"},{"label":"Dashboard","href":"https://app.rime.ai"}]}]},"integrations":{"posthog":{"apiKey":"phc_BzP0KaTCqAgNZjeq3B4EjaQPRKzthbvQZxTXBh6K7Yp","apiHost":"https://n.rime.ai","sessionRecording":true}},"errors":{"404":{"redirect":false,"title":"We can't find that page.","description":"This page does not exist or has moved.\n\n**[API reference](/docs/api-reference)**: every TTS, WebSocket, and utility endpoint\n\n**[WebSocket overview](/docs/websockets)**: endpoint and transport choices\n\n**[Five-minute quickstart](/docs/quickstart-five-minute)**: generate an audio clip\n\n**[Models](/docs/models)**: Coda and Mist v3\n\n**[Voices](/docs/voices)**: the current voice catalog\n\n**[API authentication](/docs/api-authentication)**: create and use API keys\n\n**[Changelog](/docs/changelog)**: recent changes and release notes\n\nThe machine-readable index is available at [/llms.txt](/llms.txt).\n\n[Report a broken link](mailto:support@rime.ai)."}},"contextual":{"options":["copy","view","chatgpt","claude","cursor","vscode","mcp","add-mcp"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"rimelabs","hasAudioNarration":false,"actualSubdomain":"rimelabs","customDomains":["docs.rime.ai"],"gitSource":{"type":"github","owner":"rimelabs","repo":"rime","deployBranch":"main","contentDirectory":"web/docs","isPrivate":true,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6af78bed8244b1c8e7137f30","clientVersion":"0.0.4142","searchFilterCounts":[{"language":"default","tag":"Documentation","count":93},{"language":"default","tag":"Build with Rime","count":75},{"language":"default","tag":"Text-to-speech","count":49},{"language":"default","tag":"API Reference","count":22},{"language":"default","tag":"Customizing speech","count":21},{"language":"default","tag":"Prism","count":21},{"language":"default","tag":"Integrations","count":12},{"language":"default","tag":"MCP Server","count":12},{"language":"default","tag":"CLI Reference","count":10},{"language":"default","tag":"Pronunciation","count":10}]},"assistantConfig":{},"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":"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},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":".chat-assistant-floating-input,chat-assistant-floating-input{display:none!important}a[href=\"/\"]:has(>.nav-logo){display:inline-flex;align-items:center;gap:0.5rem}a[href=\"/\"]:has(>.nav-logo)::after{color:rgb(24 24 27);content:\"docs\" / \"\";font-size:1rem;font-weight:600;letter-spacing:-0.025em;line-height:1}html.dark a[href=\"/\"]:has(>.nav-logo)::after{color:rgb(244 244 245)}html[data-current-path=\"/\"] .nav-tabs-item[data-active=\"true\"]{color:rgb(75 85 99);text-shadow:none}html.dark[data-current-path=\"/\"] .nav-tabs-item[data-active=\"true\"]{color:rgb(156 163 175)}html[data-current-path=\"/\"] .nav-tabs-item[data-active=\"true\"]>div{background-color:transparent!important}#topbar-cta-button a>span.absolute{background-color:#24211d!important}#topbar-cta-button a span,#topbar-cta-button a svg{color:#f8f3ea!important}html.dark #topbar-cta-button a>span.absolute{background-color:#f8f3ea!important}html.dark #topbar-cta-button a span,html.dark #topbar-cta-button a svg{color:#24211d!important}"}],"page":{"pagePath":"api-reference/mistv3/websockets","slug":"/api-reference/mistv3/websockets","pageMetadata":{"og:title":"Mist v3 WebSockets API | Real-Time TTS | Rime Docs","title":"Websockets","description":"Mist v3 plain-text WebSocket (/ws): send text, receive raw audio bytes.","api":"GET wss://users-ws.rime.ai/ws","authMethod":"bearer","href":"/api-reference/mistv3/websockets"},"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: \"Mist v3 plain-text WebSocket (/ws): send text, receive raw audio bytes.\"\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`,li:`li`,p:`p`,pre:`pre`,span:`span`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Note,ParamField}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`The Rime API authenticates every request with a bearer token in the `,_jsx(_components.code,{children:`Authorization`}),` header: `,_jsx(_components.code,{children:`Authorization: Bearer YOUR_API_KEY`}),`. See `,_jsx(_components.a,{href:`/docs/api-authentication`,children:`API authentication`}),` for how to create a key.`]}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[`This page describes the legacy `,_jsx(_components.code,{children:`/ws`}),` endpoint, which keeps working for existing integrations. For a new Mist v3 integration, use `,_jsx(_components.a,{href:`/api-reference/mistv3/websocket-v1`,children:`Mist v3 WebSocket v1`}),`.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`overview`,children:`Overview`}),`\n`,_jsxs(_components.p,{children:[`This WebSocket accepts plain text and returns raw audio bytes in the format you set with `,_jsx(_components.code,{children:`audioFormat`}),`. You pass every synthesis parameter as a query parameter when you open the connection, and those settings apply for the life of the connection.`]}),`\n`,_jsxs(_components.p,{children:[`The API buffers input until it detects a sentence boundary, typically at `,_jsx(_components.code,{children:`.`}),`, `,_jsx(_components.code,{children:`?`}),`, or `,_jsx(_components.code,{children:`!`}),`, so synthesis starts once it has enough text for natural prosody. The wait is most noticeable on the first sentence. After that, later text usually arrives while earlier audio is still playing, and the buffering becomes largely invisible. To change when synthesis starts, set `,_jsx(_components.code,{children:`segment`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`messages`,children:`Messages`}),`\n`,_jsx(Heading,{level:`3`,id:`send`,children:`Send`}),`\n`,_jsx(_components.p,{children:`Send bare text, not JSON.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,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:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`This will be converted to audio via websockets`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(Heading,{level:`3`,id:`receive`,children:`Receive`}),`\n`,_jsxs(_components.p,{children:[`Your client receives raw audio bytes in the `,_jsx(_components.code,{children:`audioFormat`}),` set at connection time. Append the messages in order to rebuild the audio. With `,_jsx(_components.code,{children:`pcm`}),`, a message can end mid-sample, so `,_jsx(_components.a,{href:`/docs/streaming#keep-whole-samples-in-raw-pcm`,children:`keep whole samples`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`commands`,children:`Commands`}),`\n`,_jsx(_components.p,{children:`Send these strings as text messages to control the buffer.`}),`\n`,_jsx(Heading,{level:`3`,id:`\u003cclear>`,children:_jsx(_components.code,{children:`\u003cCLEAR>`})}),`\n`,_jsx(_components.p,{children:`Discards buffered text that hasn’t been synthesized yet. Send it when the user interrupts. It doesn’t cancel a synthesis already in progress, so stop playback in your client and drop any audio that still arrives.`}),`\n`,_jsx(Heading,{level:`3`,id:`\u003cflush>`,children:_jsx(_components.code,{children:`\u003cFLUSH>`})}),`\n`,_jsx(_components.p,{children:`Synthesizes whatever text is buffered, without waiting for a sentence boundary, and sends the audio.`}),`\n`,_jsx(Heading,{level:`3`,id:`\u003ceos>`,children:_jsx(_components.code,{children:`\u003cEOS>`})}),`\n`,_jsx(_components.p,{children:`Synthesizes whatever text is buffered, sends the audio, and then the server closes the connection.`}),`\n`,_jsx(Heading,{level:`2`,id:`variable-parameters`,children:`Variable parameters`}),`\n`,_jsx(ParamField,{body:`speaker`,type:`string`,required:true,id:`param-speaker`,children:_jsxs(_components.p,{children:[`Must be a voice from the `,_jsx(_components.a,{href:`/docs/voices`,children:`Rime voice catalog`}),`.`]})}),`\n`,_jsx(ParamField,{body:`modelId`,type:`string`,id:`param-model-id`,children:_jsxs(_components.p,{children:[`Set to `,_jsx(_components.code,{children:`mistv3`}),`.`]})}),`\n`,_jsx(ParamField,{body:`audioFormat`,type:`string`,id:`param-audio-format`,children:_jsxs(_components.p,{children:[`One of `,_jsx(_components.code,{children:`wav`}),`, `,_jsx(_components.code,{children:`mp3`}),` (or `,_jsx(_components.code,{children:`mpeg`}),`), `,_jsx(_components.code,{children:`ogg`}),` (Opus in OGG), `,_jsx(_components.code,{children:`webm`}),` (Opus in WebM), `,_jsx(_components.code,{children:`pcm`}),` (or `,_jsx(_components.code,{children:`l16`}),`), or `,_jsx(_components.code,{children:`mulaw`}),` (or `,_jsx(_components.code,{children:`pcmu`}),`). Unrecognized values fall back to `,_jsx(_components.code,{children:`wav`}),`.`]})}),`\n`,_jsx(ParamField,{body:`lang`,type:`string`,default:`eng`,id:`param-lang`,children:_jsxs(_components.p,{children:[`If provided, the language must match the language spoken by the selected speaker. Verify the pairing in the `,_jsx(_components.a,{href:`/docs/voices`,children:`Rime voice catalog`}),`.`]})}),`\n`,_jsx(ParamField,{body:`pauseBetweenBrackets`,type:`bool`,default:`false`,id:`param-pause-between-brackets`,children:_jsxs(_components.p,{children:[`When set to true, adds pauses between words enclosed in angle brackets. The number inside the brackets specifies the pause duration in milliseconds.\nExample: `,_jsx(_components.code,{children:`Hi. \u003c200> I'd love to have a conversation with you.`}),` adds a 200ms pause. Learn more about `,_jsx(_components.a,{href:`/docs/custom-pauses`,children:`custom pauses`}),`.`]})}),`\n`,_jsx(ParamField,{body:`samplingRate`,type:`int`,id:`param-sampling-rate`,children:_jsx(_components.p,{children:`The sampling rate in Hz. Default: 24000. Values above 24000 are upsampled.`})}),`\n`,_jsx(ParamField,{body:`inlineSpeedAlpha`,type:`string`,id:`param-inline-speed-alpha`,children:_jsx(_components.p,{children:`Comma-separated list of speed values applied to words in square brackets. Values \u003c 1.0 speed up speech, > 1.0 slow it down.\nExample: “This is [slow] and [fast]”, use “3, 0.5” to make “slow” slower and “fast” faster.`})}),`\n`,_jsx(ParamField,{body:`speedAlpha`,type:`float`,default:`1.0`,id:`param-speed-alpha`,children:_jsx(_components.p,{children:`Adjusts the speed of speech. Higher than 1.0 is faster and lower than 1.0 is slower.`})}),`\n`,_jsxs(ParamField,{body:`segment`,type:`string`,default:`bySentence`,id:`param-segment`,children:[_jsx(_components.p,{children:`Controls how text is segmented for synthesis. Available options:`}),_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`“immediate” - Synthesizes text immediately without waiting for complete sentences`}),`\n`,_jsx(_components.li,{children:`“never” - Never segments the text, waits for explicit flush or EOS`}),`\n`,_jsx(_components.li,{children:`“bySentence” (default) - Waits for complete sentences before synthesis`}),`\n`]})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"og:title":"Mist v3 WebSockets API | Real-Time TTS | Rime Docs","title":"Websockets","description":"Mist v3 plain-text WebSocket (/ws): send text, receive raw audio bytes.","api":"GET wss://users-ws.rime.ai/ws","authMethod":"bearer","href":"/api-reference/mistv3/websockets"}}},"mdxSourceWithNoJs":{"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`,li:`li`,p:`p`,pre:`pre`,span:`span`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Note,ParamField,RequestExample}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);if(!RequestExample)_missingMdxReference(`RequestExample`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`The Rime API authenticates every request with a bearer token in the `,_jsx(_components.code,{children:`Authorization`}),` header: `,_jsx(_components.code,{children:`Authorization: Bearer YOUR_API_KEY`}),`. See `,_jsx(_components.a,{href:`/docs/api-authentication`,children:`API authentication`}),` for how to create a key.`]}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[`This page describes the legacy `,_jsx(_components.code,{children:`/ws`}),` endpoint, which keeps working for existing integrations. For a new Mist v3 integration, use `,_jsx(_components.a,{href:`/api-reference/mistv3/websocket-v1`,children:`Mist v3 WebSocket v1`}),`.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`overview`,children:`Overview`}),`\n`,_jsxs(_components.p,{children:[`This WebSocket accepts plain text and returns raw audio bytes in the format you set with `,_jsx(_components.code,{children:`audioFormat`}),`. You pass every synthesis parameter as a query parameter when you open the connection, and those settings apply for the life of the connection.`]}),`\n`,_jsxs(_components.p,{children:[`The API buffers input until it detects a sentence boundary, typically at `,_jsx(_components.code,{children:`.`}),`, `,_jsx(_components.code,{children:`?`}),`, or `,_jsx(_components.code,{children:`!`}),`, so synthesis starts once it has enough text for natural prosody. The wait is most noticeable on the first sentence. After that, later text usually arrives while earlier audio is still playing, and the buffering becomes largely invisible. To change when synthesis starts, set `,_jsx(_components.code,{children:`segment`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`messages`,children:`Messages`}),`\n`,_jsx(Heading,{level:`3`,id:`send`,children:`Send`}),`\n`,_jsx(_components.p,{children:`Send bare text, not JSON.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,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:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`This will be converted to audio via websockets`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(Heading,{level:`3`,id:`receive`,children:`Receive`}),`\n`,_jsxs(_components.p,{children:[`Your client receives raw audio bytes in the `,_jsx(_components.code,{children:`audioFormat`}),` set at connection time. Append the messages in order to rebuild the audio. With `,_jsx(_components.code,{children:`pcm`}),`, a message can end mid-sample, so `,_jsx(_components.a,{href:`/docs/streaming#keep-whole-samples-in-raw-pcm`,children:`keep whole samples`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`commands`,children:`Commands`}),`\n`,_jsx(_components.p,{children:`Send these strings as text messages to control the buffer.`}),`\n`,_jsx(Heading,{level:`3`,id:`\u003cclear>`,children:_jsx(_components.code,{children:`\u003cCLEAR>`})}),`\n`,_jsx(_components.p,{children:`Discards buffered text that hasn’t been synthesized yet. Send it when the user interrupts. It doesn’t cancel a synthesis already in progress, so stop playback in your client and drop any audio that still arrives.`}),`\n`,_jsx(Heading,{level:`3`,id:`\u003cflush>`,children:_jsx(_components.code,{children:`\u003cFLUSH>`})}),`\n`,_jsx(_components.p,{children:`Synthesizes whatever text is buffered, without waiting for a sentence boundary, and sends the audio.`}),`\n`,_jsx(Heading,{level:`3`,id:`\u003ceos>`,children:_jsx(_components.code,{children:`\u003cEOS>`})}),`\n`,_jsx(_components.p,{children:`Synthesizes whatever text is buffered, sends the audio, and then the server closes the connection.`}),`\n`,_jsx(Heading,{level:`2`,id:`variable-parameters`,children:`Variable parameters`}),`\n`,_jsx(ParamField,{body:`speaker`,type:`string`,required:true,id:`param-speaker`,children:_jsxs(_components.p,{children:[`Must be a voice from the `,_jsx(_components.a,{href:`/docs/voices`,children:`Rime voice catalog`}),`.`]})}),`\n`,_jsx(ParamField,{body:`modelId`,type:`string`,id:`param-model-id`,children:_jsxs(_components.p,{children:[`Set to `,_jsx(_components.code,{children:`mistv3`}),`.`]})}),`\n`,_jsx(ParamField,{body:`audioFormat`,type:`string`,id:`param-audio-format`,children:_jsxs(_components.p,{children:[`One of `,_jsx(_components.code,{children:`wav`}),`, `,_jsx(_components.code,{children:`mp3`}),` (or `,_jsx(_components.code,{children:`mpeg`}),`), `,_jsx(_components.code,{children:`ogg`}),` (Opus in OGG), `,_jsx(_components.code,{children:`webm`}),` (Opus in WebM), `,_jsx(_components.code,{children:`pcm`}),` (or `,_jsx(_components.code,{children:`l16`}),`), or `,_jsx(_components.code,{children:`mulaw`}),` (or `,_jsx(_components.code,{children:`pcmu`}),`). Unrecognized values fall back to `,_jsx(_components.code,{children:`wav`}),`.`]})}),`\n`,_jsx(ParamField,{body:`lang`,type:`string`,default:`eng`,id:`param-lang`,children:_jsxs(_components.p,{children:[`If provided, the language must match the language spoken by the selected speaker. Verify the pairing in the `,_jsx(_components.a,{href:`/docs/voices`,children:`Rime voice catalog`}),`.`]})}),`\n`,_jsx(ParamField,{body:`pauseBetweenBrackets`,type:`bool`,default:`false`,id:`param-pause-between-brackets`,children:_jsxs(_components.p,{children:[`When set to true, adds pauses between words enclosed in angle brackets. The number inside the brackets specifies the pause duration in milliseconds.\nExample: `,_jsx(_components.code,{children:`Hi. \u003c200> I'd love to have a conversation with you.`}),` adds a 200ms pause. Learn more about `,_jsx(_components.a,{href:`/docs/custom-pauses`,children:`custom pauses`}),`.`]})}),`\n`,_jsx(ParamField,{body:`samplingRate`,type:`int`,id:`param-sampling-rate`,children:_jsx(_components.p,{children:`The sampling rate in Hz. Default: 24000. Values above 24000 are upsampled.`})}),`\n`,_jsx(ParamField,{body:`inlineSpeedAlpha`,type:`string`,id:`param-inline-speed-alpha`,children:_jsx(_components.p,{children:`Comma-separated list of speed values applied to words in square brackets. Values \u003c 1.0 speed up speech, > 1.0 slow it down.\nExample: “This is [slow] and [fast]”, use “3, 0.5” to make “slow” slower and “fast” faster.`})}),`\n`,_jsx(ParamField,{body:`speedAlpha`,type:`float`,default:`1.0`,id:`param-speed-alpha`,children:_jsx(_components.p,{children:`Adjusts the speed of speech. Higher than 1.0 is faster and lower than 1.0 is slower.`})}),`\n`,_jsxs(ParamField,{body:`segment`,type:`string`,default:`bySentence`,id:`param-segment`,children:[_jsx(_components.p,{children:`Controls how text is segmented for synthesis. Available options:`}),_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`“immediate” - Synthesizes text immediately without waiting for complete sentences`}),`\n`,_jsx(_components.li,{children:`“never” - Never segments the text, waits for explicit flush or EOS`}),`\n`,_jsx(_components.li,{children:`“bySentence” (default) - Waits for complete sentences before synthesis`}),`\n`]})]}),`\n`,_jsx(RequestExample,{children:_jsx(CodeBlock,{filename:`Python`,numberOfLines:`50`,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:`50`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` asyncio`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` websockets`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`class`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` RimeClient`}),_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:` def`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` __init__`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`speaker`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`api_key`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.url `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"wss://users-ws.rime.ai/ws?speaker=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`speaker`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u0026modelId=mistv3\u0026audioFormat=mp3\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.auth_headers `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Bearer `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},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:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.audio_data `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` b`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`''`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` send_tokens`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`websocket`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`message`}),_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:` token `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` message:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` websocket.send(token)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` handle_audio`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`websocket`}),_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:` while`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` try`}),_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:` audio `}),_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\":`#D4D4D4`},children:` websocket.recv()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` except`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` websockets.exceptions.ConnectionClosedOK:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.audio_data `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`+=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` audio`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` run`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` with`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` websockets.connect(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.url, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`additional_headers`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.auth_headers) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` websocket:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` asyncio.gather(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.send_tokens(websocket, message),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.handle_audio(websocket),`})]}),`\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:` def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` save_audio`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`file_path`}),_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:` with`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` open`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(file_path, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'wb'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` f:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` f.write(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.audio_data)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`message `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"This \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"is \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"a \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"sentence, \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"that \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"will \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"produce \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"audio.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cEOS>\"`}),_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:`client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` RimeClient(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"cove\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},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:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"YOUR_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:`asyncio.run(client.run(message))`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client.save_audio(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"output.mp3\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"og:title":"Mist v3 WebSockets API | Real-Time TTS | Rime Docs","title":"Websockets","description":"Mist v3 plain-text WebSocket (/ws): send text, receive raw audio bytes.","api":"GET wss://users-ws.rime.ai/ws","authMethod":"bearer","href":"/api-reference/mistv3/websockets"}}}},"mdxExtracts":{"tableOfContents":[{"title":"Overview","slug":"overview","depth":2,"children":[]},{"title":"Messages","slug":"messages","depth":2,"children":[{"title":"Send","slug":"send","depth":3,"children":[]},{"title":"Receive","slug":"receive","depth":3,"children":[]}]},{"title":"Commands","slug":"commands","depth":2,"children":[{"title":"\u003cCLEAR>","slug":"\u003cclear>","depth":3,"children":[]},{"title":"\u003cFLUSH>","slug":"\u003cflush>","depth":3,"children":[]},{"title":"\u003cEOS>","slug":"\u003ceos>","depth":3,"children":[]}]},{"title":"Variable parameters","slug":"variable-parameters","depth":2,"children":[]}],"codeExamples":{"request":{"type":"RequestExample","children":[{"filename":"Python","html":"\u003cpre class=\"shiki shiki-themes github-light-default dark-plus\" style=\"background-color:#ffffff;--shiki-dark-bg:#0B0C0E;color:#1f2328;--shiki-dark:#D4D4D4\" language=\"python\">\u003ccode language=\"python\" numberOfLines=\"50\">\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">import\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> asyncio\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">import\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> websockets\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">class\u003c/span>\u003cspan style=\"color:#953800;--shiki-dark:#4EC9B0\"> RimeClient\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> def\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#DCDCAA\"> __init__\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">speaker\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">api_key\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">):\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.url \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> f\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"wss://users-ws.rime.ai/ws?speaker=\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">{\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">speaker\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">}\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\u0026#x26;modelId=mistv3\u0026#x26;audioFormat=mp3\"\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.auth_headers \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> {\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> \"Authorization\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">: \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">f\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"Bearer \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">{\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">api_key\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\">}\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> }\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.audio_data \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> b\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">''\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> async\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> def\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\"> send_tokens\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">websocket\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">message\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">):\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> for\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> token \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">in\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> message:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> await\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> websocket.send(token)\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> async\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> def\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\"> handle_audio\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">websocket\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">):\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> while\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> True\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> try\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> audio \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> await\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> websocket.recv()\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> except\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> websockets.exceptions.ConnectionClosedOK:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> break\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.audio_data \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">+=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> audio\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> async\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> def\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\"> run\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">message\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">):\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> async\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> with\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> websockets.connect(\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.url, \u003c/span>\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\">additional_headers\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.auth_headers) \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">as\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> websocket:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> await\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> asyncio.gather(\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.send_tokens(websocket, message),\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\"> self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.handle_audio(websocket),\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> )\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#569CD6\"> def\u003c/span>\u003cspan style=\"color:#8250DF;--shiki-dark:#DCDCAA\"> save_audio\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#9CDCFE\">file_path\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">):\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\"> with\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#DCDCAA\"> open\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">(file_path, \u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">'wb'\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">) \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#C586C0\">as\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> f:\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> f.write(\u003c/span>\u003cspan style=\"color:#0550AE;--shiki-dark:#569CD6\">self\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">.audio_data)\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">message \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> [\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> \"This \"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> \"is \"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> \"a \"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> \"sentence, \"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> \"that \"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> \"will \"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> \"produce \"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> \"audio.\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\"> \"\u0026#x3C;EOS>\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">,\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">]\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">client \u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\"> RimeClient(\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"cove\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">, \u003c/span>\u003cspan style=\"color:#953800;--shiki-dark:#9CDCFE\">api_key\u003c/span>\u003cspan style=\"color:#CF222E;--shiki-dark:#D4D4D4\">=\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"YOUR_API_KEY\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">)\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">asyncio.run(client.run(message))\u003c/span>\u003c/span>\n\u003cspan class=\"line\">\u003c/span>\n\u003cspan class=\"line\">\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">client.save_audio(\u003c/span>\u003cspan style=\"color:#0A3069;--shiki-dark:#CE9178\">\"output.mp3\"\u003c/span>\u003cspan style=\"color:#1F2328;--shiki-dark:#D4D4D4\">)\u003c/span>\u003c/span>\n\u003c/code>\u003c/pre>"}],"attributes":[]}},"endpoint":{"title":"Websockets","path":"/ws","servers":[{"url":"wss://users-ws.rime.ai"}],"method":"get","request":{"security":[{"title":"Bearer Auth","parameters":{"header":{"Authorization":{"type":"http","scheme":"bearer","description":"Bearer authentication header of the form `Bearer \u003ctoken>`, where `\u003ctoken>` is your auth token."}},"query":{},"cookie":{}}}],"parameters":{"query":{},"header":{},"cookie":{},"path":{}},"body":{"application/json":{"schemaArray":[{"type":"object","properties":{"speaker":[{"type":"string","description":"Must be a voice from the Rime voice catalog .","required":true}],"modelId":[{"type":"string","description":"Set to `mistv3` ."}],"audioFormat":[{"type":"string","description":"One of `wav` , `mp3` (or `mpeg` ), `ogg` (Opus in OGG), `webm` (Opus in WebM), `pcm` (or `l16` ), or `mulaw` (or `pcmu` ). Unrecognized values fall back to `wav` ."}],"lang":[{"type":"string","description":"If provided, the language must match the language spoken by the selected speaker. Verify the pairing in the Rime voice catalog ."}],"pauseBetweenBrackets":[{"type":"boolean","description":"When set to true, adds pauses between words enclosed in angle brackets. The number inside the brackets specifies the pause duration in milliseconds. Example: `Hi. \u003c200> I'd love to have a conversation with you.` adds a 200ms pause. Learn more about custom pauses ."}],"samplingRate":[{"type":"integer","description":"The sampling rate in Hz. Default: 24000. Values above 24000 are upsampled."}],"inlineSpeedAlpha":[{"type":"string","description":"Comma-separated list of speed values applied to words in square brackets. Values \u003c 1.0 speed up speech, > 1.0 slow it down. Example: “This is [slow] and [fast]”, use “3, 0.5” to make “slow” slower and “fast” faster."}],"speedAlpha":[{"type":"number","description":"Adjusts the speed of speech. Higher than 1.0 is faster and lower than 1.0 is slower."}],"segment":[{"type":"string","description":"Controls how text is segmented for synthesis. Available options: “immediate” - Synthesizes text immediately without waiting for complete sentences “never” - Never segments the text, waits for explicit flush or EOS “bySentence” (default) - Waits for complete sentences before synthesis"}]}}],"examples":{"example":{"value":{"speaker":"\u003cstring>","modelId":"\u003cstring>","audioFormat":"\u003cstring>","lang":"\u003cstring>","pauseBetweenBrackets":true,"samplingRate":123,"inlineSpeedAlpha":"\u003cstring>","speedAlpha":123,"segment":"\u003cstring>"}}}}}},"response":{},"deprecated":false}},"jsLinks":[],"subdomain":"rimelabs","siteName":"Rime Docs","title":"Mist v3 WebSockets API | Real-Time TTS | Rime Docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-22T16:11:34.354Z","originalFileLocation":"api-reference/mistv3/websockets.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=\"Mist v3 plain-text WebSocket (/ws): send text, receive raw audio bytes.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Rime Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/rimelabs/yDOD7F9UdOtEHeIJ/_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/rimelabs/yDOD7F9UdOtEHeIJ/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/rimelabs/yDOD7F9UdOtEHeIJ/_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/rimelabs/yDOD7F9UdOtEHeIJ/_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/rimelabs/yDOD7F9UdOtEHeIJ/_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/rimelabs/yDOD7F9UdOtEHeIJ/_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/rimelabs/yDOD7F9UdOtEHeIJ/_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/rimelabs/yDOD7F9UdOtEHeIJ/_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/rimelabs/yDOD7F9UdOtEHeIJ/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Mist v3 WebSockets API | Real-Time TTS | Rime Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Mist v3 plain-text WebSocket (/ws): send text, receive raw audio bytes.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Rime Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.rime.ai/api-reference/mistv3/websockets\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://rimelabs.mintlify.site/_mintlify/api/og/v2?division=Legacy+WebSockets\u0026amp;title=Websockets\u0026amp;description=Mist+v3+plain-text+WebSocket+%28%2Fws%29%3A+send+text%2C+receive+raw+audio+bytes.\u0026amp;theme=219ecb54f4eb0df981d92f9e\u0026amp;signature=c298253d2cb84d2d62f23eaa74d4b9adb303d81baa3be14c546e8f796a9bacf4\">\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=\"Mist v3 WebSockets API | Real-Time TTS | Rime Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Mist v3 plain-text WebSocket (/ws): send text, receive raw audio bytes.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://rimelabs.mintlify.site/_mintlify/api/og/v2?division=Legacy+WebSockets\u0026amp;title=Websockets\u0026amp;description=Mist+v3+plain-text+WebSocket+%28%2Fws%29%3A+send+text%2C+receive+raw+audio+bytes.\u0026amp;theme=219ecb54f4eb0df981d92f9e\u0026amp;signature=c298253d2cb84d2d62f23eaa74d4b9adb303d81baa3be14c546e8f796a9bacf4\">\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/rimelabs/yDOD7F9UdOtEHeIJ/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Rime Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#1DADC7\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.rime.ai/api-reference/mistv3/websockets\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api-reference/mistv3/websockets.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.rime.ai/#organization\",\"name\":\"Rime Docs\",\"url\":\"https://docs.rime.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/rimelabs/qBNCx7nLDEv-FtZq/logo/light.png?fit=max\u0026auto=format\u0026n=qBNCx7nLDEv-FtZq\u0026q=85\u0026s=b74ee12f1a1075334db19359152c2f8a\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.rime.ai#website\",\"name\":\"Rime Docs\",\"url\":\"https://docs.rime.ai\",\"publisher\":{\"@id\":\"https://docs.rime.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.rime.ai/api-reference/mistv3/websockets#webpage\",\"url\":\"https://docs.rime.ai/api-reference/mistv3/websockets\",\"name\":\"Websockets\",\"description\":\"Mist v3 plain-text WebSocket (/ws): send text, receive raw audio bytes.\",\"dateModified\":\"2026-10-22T16:11:34.354Z\",\"isPartOf\":{\"@id\":\"https://docs.rime.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.rime.ai/api-reference/mistv3/websockets#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.rime.ai/api-reference/mistv3/websockets#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Mist v3 API reference\",\"item\":\"https://docs.rime.ai/api-reference/mistv3/http\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Websockets\",\"item\":\"https://docs.rime.ai/api-reference/mistv3/websockets\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.rime.ai/api-reference/mistv3/websockets#apireference\",\"headline\":\"Websockets\",\"name\":\"Websockets\",\"description\":\"Mist v3 plain-text WebSocket (/ws): send text, receive raw audio bytes.\",\"url\":\"https://docs.rime.ai/api-reference/mistv3/websockets\",\"mainEntityOfPage\":{\"@id\":\"https://docs.rime.ai/api-reference/mistv3/websockets#webpage\"},\"dateModified\":\"2026-10-22T16:11:34.354Z\",\"publisher\":{\"@id\":\"https://docs.rime.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.rime.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Rime Docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Rime Docs\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/api-reference/mistv3/websockets.md","siteName":"Rime Docs","nav":{"global":null,"tabs":[{"tab":"Home","hidden":true,"searchable":true,"pages":[{"title":"Home","href":""}]},{"tab":"Documentation","pages":[{"title":"Documentation","href":"/docs/introduction"}]},{"tab":"API Reference","groups":[{"group":"Overview","pages":[{"title":"API reference index","href":"/docs/api-reference"},{"title":"API cheat sheet","icon":"list-check","href":"/docs/api-cheat-sheet"}]},{"group":"Coda API reference","pages":[{"title":"Streaming HTTP","api":"POST https://coda.api.rime.ai/","href":"/api-reference/coda/http"},{"group":"WebSocket v1","pages":[{"title":"Coda WebSocket API","sidebarTitle":"API reference","href":"/api-reference/coda/websocket-v1"},{"title":"JSON quickstart","href":"/api-reference/coda/websocket-v1-json"},{"title":"Protobuf quickstart","href":"/api-reference/coda/websocket-v1-protobuf"},{"title":"LiveKit integration","href":"/api-reference/coda/websocket-v1-livekit"}]},{"group":"Legacy WebSockets","pages":[{"title":"Legacy WebSocket (/ws)","sidebarTitle":"Legacy /ws","api":"GET wss://users-ws.rime.ai/ws","href":"/api-reference/coda/websockets"},{"title":"Legacy JSON WebSocket (/ws3)","sidebarTitle":"Legacy /ws3 JSON","api":"GET wss://users-ws.rime.ai/ws3","href":"/api-reference/coda/websockets-json"}]}]},{"group":"Mist v3 API reference","pages":[{"title":"Streaming HTTP","api":"POST https://mist.api.rime.ai/","href":"/api-reference/mistv3/http"},{"group":"WebSocket v1","pages":[{"title":"Mist v3 WebSocket API","sidebarTitle":"API reference","description":"Stream Mist v3 speech over the WebSocket v1 protocol. This reference covers the endpoint, how Mist differs from Coda, the Mist parameters, word timestamps, and the LiveKit plugin.","href":"/api-reference/mistv3/websocket-v1"}]},{"group":"Legacy WebSockets","pages":[{"title":"Websockets","api":"GET wss://users-ws.rime.ai/ws","href":"/api-reference/mistv3/websockets"},{"title":"Websockets JSON","description":"Mist v3 JSON WebSocket (/ws3): structured events with base64 audio chunks and word-level timestamps.","api":"GET wss://users-ws.rime.ai/ws3","href":"/api-reference/mistv3/websockets-json"}]}]},{"group":"Speech-to-text API reference","pages":[{"title":"Streaming WebSocket","href":"/api-reference/stt/websockets"},{"title":"gRPC","href":"/api-reference/stt/grpc"}]},{"group":"Prism API reference","pages":[{"title":"Prism WebSocket","href":"/api-reference/prism/websocket"},{"title":"Prism LiveKit plugin reference","sidebarTitle":"LiveKit plugin","icon":"video","href":"/api-reference/prism/livekit"}]},{"group":"API Metadata","pages":[{"title":"List All Voices","api":"GET https://users.rime.ai/data/voices/all-v2.json","href":"/api-reference/data/voices-v2"},{"title":"List Voice Details","api":"GET https://users.rime.ai/data/voices/voice_details.json","href":"/api-reference/data/voice-details"}]},{"group":"Other APIs","pages":[{"title":"Coverage","sidebarTitle":"Vocabulary Coverage","api":"POST https://users.rime.ai/oov","href":"/api-reference/other/oov"},{"title":"Phonemize","sidebarTitle":"Phonemize Audio","api":"POST https://optimize.rime.ai/phonemize","href":"/api-reference/other/phonemize"},{"title":"Text Normalization","api":"POST https://optimize.rime.ai/textnorm","href":"/api-reference/other/textnorm"}]}]},{"tab":"SDK Reference","pages":[{"title":"SDK Reference","href":"/api-reference/sdk/overview"}]},{"tab":"CLI Reference","pages":[{"title":"CLI Reference","href":"/cli-reference/overview"}]},{"tab":"MCP Server","pages":[{"title":"MCP Server","href":"/mcp-reference/overview"}]}]},"basePath":"","title":"Mist v3 WebSockets API | Real-Time TTS | Rime Docs","buildId":"dpl_G2Qd45vZZ7MkBiGF9yYx8ZsbbKXX","deploymentId":"dpl_G2Qd45vZZ7MkBiGF9yYx8ZsbbKXX","dynamics":["c2aa737661","2b790eda92","b0f84f53ff"],"chunks":["OpenApiReferenceProvider-NXj-Rqjv.js","utils-m0thOP-_.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-D13EKcfm.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema--XTdfsEb.js","snippetPresets-D3s4lmAH.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","conditional-requirements-CFM0id0Q.js","ApiExamples-ChURybxL.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-DL8CiXq2.js","shallow-DI2-YB2E.js","getApiPlaygroundDisplay-DxbW7b_y.js","CodeSnippet-CiNYS0pP.js","CodeSnippets-BT87bThu.js","Page-DSpdRuhM.js","getPastedJson-F_g_IrFQ.js","icon-CCIG5BAs.js","MethodPill-DY3E0jwx.js","DuplicateIcon-BN88xnEg.js","createIcon-VCCc5HO5.js","DynamicMarkdown-CaSwclgK.js","SectionHeading-DXV8nWhc.js","axios-vUo_bRtp.js"]}