What you will build
- A Go backend that keeps Partner Token and Suki Token on the server.
- An Ambient visit flow you can run yourself: create session, attach context, stream PCM, end, and retrieve the note.
- Working Go examples for every Ambient REST and WebSocket step you need.
Agenda
In this tutorial, you learn how to implement Suki Ambient APIs in Go and run one ambient session from start to finish. You will learn how to:- Authenticate with Partner ID and Partner Token, and keep tokens on the server.
- Create an ambient session and attach provider, patient, visit, and note section context.
- Open
wss://โฆ/ws/stream, sendSTART_TIME, stream LINEAR16 PCM as JSON audio frames, and end withRU9G. - End the session over REST, poll status, then retrieve content, transcript, and structured data.
- Optionally set note style with user preferences and submit note feedback.
The sample is not a public GitHub repo. Use the file explorer below to browse the code, or click Run locally to download a zip. Credentials are not included. Copy the patterns you need into your own backend.
What you build
You build a small clinic UI inside a Go application. The browser never calls Suki directly. Your Go server holds credentials, opens Ambient sessions, and forwards microphone PCM to Suki. This tutorial covers only the Ambient Partner API path in the steps below. Clinic schedule UI, Dictation, and a fake EHR send are also in the sample. Browse the full partner sample in the explorer.Browse the sample project
Use the sidebar in the explorer to open files from the ambient-api-starter sample. Partner credentials are not included. Use.env.example as the template. Run locally downloads a zip you unzip and run with Go on your machine (it cannot run inside the browser).
Ambient APIs used for this tutorial
Staging hosts you use while you learn:
When you move to production, switch to
https://sdp.suki.ai and wss://sdp.suki.ai. See Ambient API overview.
Architecture
Follow this Ambient visit order in your Go backend:Best practices you follow in this tutorial
Use these practices as you build your backend.Prerequisites and dependencies
- Prerequisites
- Dependencies
Before you begin, make sure you have:
- Go 1.22+ installed.
- Completed Partner onboarding and received staging Partner ID.
- Chrome or Edge with microphone permission for a live visit test.
Project setup
- Create a Go module for your backend.
- Add
github.com/gorilla/websocket. - Put Partner credentials in a local
.envor secret store. Do not commit them. - Plan to send LINEAR16 PCM at 16 kHz, mono, 16-bit little-endian. If your UI captures browser audio, resample to that format before you forward bytes to Suki.
Tutorial steps
Go through each step in order. Read the explanation, copy the Go example, then continue. Every code block is written in Go and follows the Ambient API path.1
Log In and Keep the Suki Token
Call Login with Partner ID and Partner Token. Send the returned For every subsequent REST call, set the following headers:
suki_token later as the sdp_suki_token header. If the provider is new, call Register once, then log in again.In the demo UI, clinic sign in stays in the browser. Partner Token stays in .env on the Go server.Code example2
Open a Visit from the Clinic UI
Before you create an ambient session, run the sample locally so you have a clinic UI and a patient chart ready.
- In the explorer above, click Run locally to download
suki-partner-samples.zip. - Unzip the archive, then
cd ambient-api-starter. - Copy
.env.exampleto.envand set your staging Partner ID and Partner Token. - Run
go run ./cmd/server, then openhttp://127.0.0.1:8080. - Register or sign in to the demo clinic, open Appointments, and add a walk-in or open a scheduled visit so a patient chart is ready.
ambient-api-starter/internal/suki/client.go to see how login and session helpers are wired before the next steps.3
Create an Ambient Session
Call Create ambient session. The response includes
ambient_session_id (required for streaming) and often composition_id (useful for note-scoped structured data).4
Attach Session Context
Send provider specialty, patient demographics, visit details, and LOINC note sections with Session context. Suki uses this chart context when writing the note.
Do not put verbosity or section format in session context. Set those with
PATCH /api/v1/user/preferences before recording starts.5
Open the Ambient WebSocket and Stream PCM
Dial Ambient audio streaming at Pause and resume use stream events (same session):
/ws/stream. Authenticate with HTTP headers from Go (sdp_suki_token, ambient_session_id, and sdp_provider_id when required).On the patient chart in the local demo, start Ambient from the microphone control. The browser sends PCM to your Go server at ws://127.0.0.1:8080/ws/pcm, and Go forwards it to Suki on /ws/stream.While you implement this step:- Keep
go run ./cmd/serverrunning from Step 2. - In the explorer, open
ambient-api-starter/internal/suki/stream.go(and related session helpers) to match the dial,START_TIME,AUDIO, andRU9Gorder. - On the chart, start Ambient, speak a short fake visit, then stop. Confirm your server logs show frames forwarding without Partner Token errors.
START_TIME first, then base64 PCM chunks in AUDIO frames. Chunk about 3200 bytes (about 100 ms of 16 kHz mono 16-bit). Keep sending audio at least every 25 seconds, or send KEEP_ALIVE while paused.6
End the Session and Poll for the Note
When the visit stops, send the ambient end marker End the stream and poll for results like this:
RU9G, close the WebSocket, then call End ambient session. Poll Session status until completed, then fetch content.7
Optional: Note Style and Feedback
Set verbosity and section format with User preferences before you start recording. After the note is ready, submit a 1 to 5 rating with content feedback.
Full Ambient start flow
Use one function to run the start path: login, create the session, attach context, then open the WebSocket stream.ws://127.0.0.1:8080/ws/pcm. Your Go process then calls stream.SendPCM(pcm) toward Suki. Capture audio any way your product needs, as long as the bytes you send to /ws/stream are LINEAR16 PCM.
How this tutorial was tested
This tutorial is tested on the following:- Go 1.22+ on macOS
- Staging endpoints
https://sdp.suki-stage.comandwss://sdp.suki-stage.com - Local server start with
go run ./cmd/serveronhttp://127.0.0.1:8080 - Partner ID and Partner Token from a staging partner account in local
.env - Demo clinic register or sign in in Chrome
- Ambient visit on the patient chart: start recording, stream microphone PCM through the Go server, stop, poll status, and retrieve note content
- Fake clinical speech only (do not record real patients)
Common mistakes
Next steps
Build an ambient streaming client - End-to-end login, stream, and retrieve in another tutorial. Ambient audio streaming -/ws/stream order, auth headers, and chunking.
Retrieve ambient content - Load note sections, transcript, and structured data after completed.
Partner authentication - Keep Partner Token and Suki Token on the server.
Create ambient session - Request and response fields for session create.