Skip to main content
What you will build

35 min | Intermediate

  • 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.
Using an AI coding tool?Copy the prompt below to point your agent at the Ambient and audio streaming skills and Documentation MCP. For every task skill, refer to AI coding tools.

Fetch the Ambient and audio streaming skills and connect the documentation MCP.

Open in Cursor

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:
  1. Authenticate with Partner ID and Partner Token, and keep tokens on the server.
  2. Create an ambient session and attach provider, patient, visit, and note section context.
  3. Open wss://โ€ฆ/ws/stream, send START_TIME, stream LINEAR16 PCM as JSON audio frames, and end with RU9G.
  4. End the session over REST, poll status, then retrieve content, transcript, and structured data.
  5. Optionally set note style with user preferences and submit note feedback.
Go through each step, copy the code examples into your product, and follow the same API sequence in your product.
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.
By the end, you can map which Ambient APIs to call, in which order, with working Go code for each step.

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

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.
Set these environment variables when you run locally:
Store Partner Token and Suki Token only on your backend. Never put them in browser JavaScript.

Project setup

  1. Create a Go module for your backend.
  2. Add github.com/gorilla/websocket.
  3. Put Partner credentials in a local .env or secret store. Do not commit them.
  4. 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.
Your backend should have this shape:

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 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 example
For every subsequent REST call, set the following headers:
2

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.
  1. In the explorer above, click Run locally to download suki-partner-samples.zip.
  2. Unzip the archive, then cd ambient-api-starter.
  3. Copy .env.example to .env and set your staging Partner ID and Partner Token.
  4. Run go run ./cmd/server, then open http://127.0.0.1:8080.
  5. 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.
The clinic schedule is demo UI only. Suki Ambient does not require a booked calendar slot. Your Go backend still runs the same create session and stream path for a walk-in or a scheduled visit.In the explorer, open 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 /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:
  1. Keep go run ./cmd/server running from Step 2.
  2. In the explorer, open ambient-api-starter/internal/suki/stream.go (and related session helpers) to match the dial, START_TIME, AUDIO, and RU9G order.
  3. On the chart, start Ambient, speak a short fake visit, then stop. Confirm your server logs show frames forwarding without Partner Token errors.
Send 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.
Pause and resume use stream events (same session):
6

End the Session and Poll for the Note

When the visit stops, send the ambient end marker RU9G, close the WebSocket, then call End ambient session. Poll Session status until completed, then fetch content.
End the stream and poll for results like this:
Very short recordings are often skipped. When you test Ambient note generation, aim for about one minute of clinical speech.
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.
In a UI-backed demo, the browser can send mic PCM to your local Go process over 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.com and wss://sdp.suki-stage.com
  • Local server start with go run ./cmd/server on http://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.
Last modified on September 29, 2026