Skip to main content

Suki Dictation SDK

Embed real-time clinical dictation into browser applications using the Suki Dictation SDK. Supports:
  • In-field dictation overlays
  • Scratchpad dictation surfaces
  • Framework-agnostic JavaScript usage
  • First-class React integration
  • Secure SDP authentication lifecycle

Quickstart

Install

npm install @suki-sdk/dictation @suki-sdk/core

Initialize

import { SukiAuthManager } from "@suki-sdk/core"
import { DictationClient } from "@suki-sdk/dictation"

const authManager = new SukiAuthManager({
  partnerId: "YOUR_PARTNER_ID",
  partnerToken: "YOUR_PARTNER_TOKEN",
  environment: "staging",
  loginOnInitialize: true
})

const client = new DictationClient({ authManager })

await client.show({
  mode: "in-field",
  fieldId: "notes",
  rootElement: document.getElementById("dictation-root"),
  onSubmit: ({ text }) => console.log(text)
})
Tip: This is the minimal working integration. Most applications only need to customize callbacks and container placement.

Choosing the Right Package

ScenarioPackage
Dictation only (JavaScript)@suki-sdk/dictation
Dictation only (React)@suki-sdk/dictation-react

Architecture Overview

The SDK embeds dictation using a sandboxed iframe controlled by a lightweight lifecycle client.
Your App

DictationClient

IframeMessenger

Dictation iframe (Suki hosted)
Layer responsibilities:
LayerResponsibility
ApplicationDecides when and where dictation appears
DictationClientManages session lifecycle
SukiAuthManagerHandles authentication + token refresh
IframeSpeech UI + transcription engine
Note: The iframe is isolated from host CSS and DOM to ensure consistent rendering across integrations.

Installation

JavaScript apps:
npm install @suki-sdk/dictation @suki-sdk/core
React apps:
npm install @suki-sdk/dictation-react @suki-sdk/core

Authentication

All integrations begin with SukiAuthManager.
new SukiAuthManager({
  partnerId,
  partnerToken,
  environment: "staging",
  loginOnInitialize: true
})
Responsibilities:
  • Validates configuration
  • Authenticates with SDP
  • Refreshes tokens automatically
  • Provides iframe credentials
Warning: Invalid credentials will prevent iframe initialization.

Initialization Lifecycle

Create AuthManager

(optional) login()

Create DictationClient

show()

Session active

hide()
React integrations automatically manage show() and hide().

JavaScript Integration

Use the imperative API when integrating with:
  • Vanilla JS apps
  • Non-React frameworks
  • Multiple dynamic editors
  • Custom overlay systems
await dictationClient.show({
  mode: "in-field",
  fieldId: "assessment",
  rootElement,
  initialText,
  onSubmit,
  onCancel
})
The iframe automatically resizes to match the container element.

React Integration

Wrap once:
<DictationProvider client={client}>
Render conditionally:
{activeField === "notes" && (
  <Dictation
    fieldId="notes"
    mode="in-field"
    initialText={value}
    onSubmit={handleSubmit}
  />
)}
Unmounting automatically calls hide().
Tip: Use state like activeFieldId to control which input owns the dictation session.

Dictation Modes

Two interaction modes are supported:
ModeBehavior
in-fieldOverlays input container
scratchpadFloating standalone dictation UI
mode: "scratchpad"
Use scratchpad when dictation is not tied to a specific input field.

Switching Between Fields

Calling show() again automatically replaces the active session.
show(fieldA)
show(fieldB)
This is equivalent to:
hide(fieldA)
show(fieldB)
Manual cleanup is not required.

Callback Contract

All callbacks receive:
{
  fieldId: string,
  text: string
}
Supported callbacks:
CallbackRequiredPurpose
onSubmitYesCommit dictation result
onCancelOptionalDiscard session
onDraftOptionalUnstaged text when user does not submit and switches context; partner persists only if they handle it
Example:
onSubmit: ({ fieldId, text }) => save(fieldId, text)

Configuration Reference

AuthConfig

FieldRequiredDescription
partnerIdYesPartner identifier
partnerTokenYesPartner auth token
environmentOptional"staging" or "production"
autoRegisterOptionalEnable provider auto-registration
loginOnInitializeOptionalLogin during construction
Provider metadata may be required when auto-registration is enabled.

ShowOptions

FieldRequiredDescription
modeYes"in-field" or "scratchpad"
fieldIdYesIdentifier echoed in callbacks
rootElementRecommendedContainer element for iframe
initialTextOptionalSeed content
onSubmitYesCompletion callback
onCancelOptionalCancellation callback
onDraftOptionalUnstaged text when the user does not submit and moves on (for example, another field); not per-keystroke streaming

Runtime Requirements

Supported environments:
  • ✅ Browser
  • ❌ Node.js
  • ❌ SSR iframe rendering
The SDK depends on:
  • HTMLIFrameElement
  • postMessage
  • DOM layout sizing

Best Practices

Use a wrapper container instead of attaching directly to inputs:
textarea-wrapper
    └── iframe overlay
Recommended CSS:
.wrapper {
  position: relative;
  height: 100%;
}
This ensures stable overlay positioning.

Error Handling

Most integration errors originate from:
SourceCause
AuthManagerInvalid credentials
iframeBlocked domain / CSP
ConfigurationMissing callbacks
LayoutContainer has zero height
Example:
try {
  await client.show(...)
} catch (err) {
  console.error(err)
}

Troubleshooting

Dictation UI not visible

Check:
  • Container height
  • CSP iframe restrictions
  • Missing rootElement
  • Authentication failure

Dictation closes immediately

Usually indicates a missing onSubmit callback.

Multiple overlays appearing

Ensure only one DictationClient instance exists per page scope.
Last modified on April 20, 2026