Skip to main content
What you will build

15 min | Intermediate

  • Login and create a Dictation session
  • Stream raw PCM audio over WebSocket
  • Read partial and final transcript frames
  • End the session and print the final transcript
  • Handle common API errors
Using an AI coding tool?Copy the following prompt to add the Suki developer documentation as a skill and MCP server to your tool for better AI-assisted coding during the integration process. For all AI options (contextual menu, llms.txt, and skill.md), refer to AI-optimized documentation.

Install the Suki developer docs as a skill to get context on Suki's developer tools, APIs, and SDKs. Add the MCP server for documentation search.

Open in Cursor
In this tutorial, you build an end-to-end Dictation streaming client. You authenticate, create a transcription session, stream PCM audio over a WebSocket connection, read partial and final transcript frames, end the session, and print the final transcript from the end response. Examples are provided in Python, TypeScript, and Go coding languages. By the end of this tutorial, you’ll have a working client that connects to the production endpoints https://sdp.suki.ai and wss://sdp.suki.ai/ws/transcribe, and handles common API errors.

Prerequisites

Before you begin, make sure you have:
  • Completed Partner onboarding and received your partner credentials.
  • You have partner_id and partner_token.
  • Optional provider_id or sdp_provider_id if your integration uses Bearer authentication or the Single Auth Token flow.
  • An audio file in LINEAR16 PCM format (16 kHz, mono, 16-bit little-endian). If you’re using a WAV file, remove the WAV header before streaming and send only the raw PCM audio.
Store your partner_token only on your backend. Never expose it in a client-side or public application.

Architecture

Project setup

  1. Create a script or web page in the language used by this tutorial (Python, Go, or TypeScript).
  2. Install the required dependencies:
    • Python: pip install requests websocket-client
    • Go: go get github.com/gorilla/websocket
    • TypeScript (browser): No additional packages are required. The example uses the built-in fetch and WebSocket APIs.
  3. Configure your credentials:
    • Add your partner_id.
    • Store partner_token on your backend only. Never expose it in browser code.
    • Add provider_id or sdp_provider_id only if your integration requires them.
  4. Prepare an audio file in LINEAR16 PCM format or a WAV file. If you use a WAV file, remove the 44-byte WAV header before streaming the PCM audio.

How WebSocket authentication works in this tutorial

Important points to remember:
  • If login fails because the provider is new, Register provider once, then log in again.
  • Open /ws/transcribe only when the session is READY or IDLE.
  • Use Dictation frame types on this endpoint. Do not send ambient START_TIME, RU9G, or ambient AUDIO data frames.
  • Browser protocol order for Dictation is token, then session ID.

Tutorial steps

Work through each step in order. Read the explanation, review the code example, then continue to the next step. The full code example is available in the accordion below.
1

Log In

Call the Login API with your partner credentials to receive a suki_token. Send that token later as sdp_suki_token. If the provider is new, register once, then log in again.
2

Create a Dictation Session

Create a session with the Create Dictation session API. A successful response returns transcription_session_id (HTTP 201).
3

Open the WebSocket

Open wss://sdp.suki.ai/ws/transcribe only when the session is READY or IDLE. Authenticate with headers (Python/Go) or Sec-WebSocket-Protocol (browser).
4

Stream Audio

Send JSON AUDIO messages with base64 PCM in audioData. When finished, send EVENT / AUDIO_END. Do not send binary frames or ambient RU9G.
5

Read Transcript Frames

Read inbound frames until EOF. Collect finals where is_final is true. See Read Dictation transcript frames.
6

End the Session and Get the Transcript

Close the WebSocket, then call End Dictation session. Use final_transcript from the response.
7

Handle API Errors

Map REST failures using documented code, message, and details. See API error messages.

Full code example

Python

Troubleshooting

Open /ws/transcribe only when the session is READY or IDLE, not RUNNING or COMPLETED.
Use Dictation audioData and AUDIO_END. Do not send ambient START_TIME, RU9G, or ambient AUDIO data frames on this endpoint.
Dictation uses SukiAmbientAuth,<sdp_suki_token>,<transcription_session_id> (token before session ID). See the auth table above.

Summary

In this tutorial, you:
  • Authenticated with the Suki API.
  • Created a Dictation session and opened /ws/transcribe.
  • Streamed LINEAR16 PCM audio and read transcript frames.
  • Ended the session and printed the final transcript.
For production, use the following endpoints:
  • API: https://sdp.suki.ai
  • WebSocket: wss://sdp.suki.ai/ws/transcribe

Other tutorials

Continue with another end-to-end tutorial.
Dictation

Build Dictation into a Chart Field

Mount Dictation in-field mode on a chart textarea with one shared DictationClient in React.

15 minIntermediate
Ambient

Build an Ambient Streaming Client

Authenticate, create a session, stream PCM audio over WebSocket, and retrieve clinical note results.

20 minIntermediate
Last modified on July 24, 2026