@corti/sdk package exports four main APIs:
| Export | Import | Purpose |
|---|---|---|
CortiClient | import { CortiClient } from "@corti/sdk" | Full API client with all resource groups, authentication, and WebSockets |
CortiAuth | import { CortiAuth } from "@corti/sdk" | Standalone authentication client for token management and OAuth flows |
CortiWebSocketProxyClient | import { CortiWebSocketProxyClient } from "@corti/sdk" | WebSocket-only proxy client for stream and transcribe |
| Utilities | import { ... } from "@corti/sdk/utils" | Token decoding, environment resolution, and PKCE helpers |
CortiClient
The main client for all Corti API operations.Constructor options
JavaScript
| Option | Type | Default | Description |
|---|---|---|---|
environment | CortiEnvironment | CortiEnvironmentUrls | string | Required | API region or custom URLs |
tenantName | string | Required | Your Corti tenant name |
auth | CortiClient.Auth | Required | Authentication configuration (all flows) |
headers | Record<string, string> | undefined | Headers sent with every request |
timeoutInSeconds | number | 60 | Default request timeout |
maxRetries | number | 2 | Default retry count |
fetcher | (url, init) => Promise<Response> | undefined | Custom fetch implementation |
logging | { level, logger, silent } | { silent: true } | Logging config |
withCredentials | boolean | false | Include cookies in CORS requests |
encodeHeadersAsWsProtocols | boolean | false | Encode auth as WS subprotocols (for restrictive gateways) |
baseUrl | string | undefined | Route all traffic through a proxy |
Request options
Every HTTP method accepts an optional request options object as the last argument:JavaScript
| Option | Type | Description |
|---|---|---|
timeoutInSeconds | number | Override the default 60s timeout |
maxRetries | number | Override the default 2 retries |
abortSignal | AbortSignal | Cancel the request |
headers | Record<string, string> | Additional HTTP headers |
queryParams | Record<string, string> | Additional query string parameters |
Resource groups
The client exposes the following resource groups as properties:| Group | Description | API endpoints |
|---|---|---|
client.interactions | Manage patient encounters and interaction sessions | Interactions API |
client.recordings | Upload and retrieve audio recordings for interactions | Recordings API |
client.transcripts | Create and retrieve transcriptions of recordings | Transcripts API |
client.documents | Generate and manage AI-produced clinical documents | Documents API |
client.facts | Extract and manage structured clinical facts | Facts API |
client.templates | List and retrieve document generation templates | Templates API |
client.codes | Predict medical codes from clinical data | Codes API |
client.agents | Create and interact with AI agents | Agents API |
client.stream | Real-time WebSocket streaming (transcription + facts) | Stream API |
client.transcribe | Real-time WebSocket speech-to-text (standalone) | Transcribe API |
client.auth | OAuth token management and authorization URLs | Auth API |
Interactions
Manage interaction sessions that group recordings, transcripts, documents, and facts together.| Method | Parameters | Returns |
|---|---|---|
list(request?) | Filter and pagination options | Paginated list of interactions |
create(request) | Interaction definition | Created interaction |
get(id) | Interaction UUID | Single interaction |
update(id, request?) | Interaction UUID + update fields | Updated interaction |
delete(id) | Interaction UUID | void |
Recordings
Upload and manage audio recordings within an interaction.JavaScript
| Method | Parameters | Returns |
|---|---|---|
upload(file, interactionId) | Uploadable file + interaction UUID | Created recording |
list(interactionId) | Interaction UUID | List of recordings |
get(interactionId, recordingId) | Interaction UUID + recording UUID | Binary audio data |
delete(interactionId, recordingId) | Interaction UUID + recording UUID | void |
Transcripts
Create transcriptions from uploaded recordings and retrieve results.JavaScript
| Method | Parameters | Returns |
|---|---|---|
create(interactionId, request) | Interaction UUID + transcript definition | Created transcript |
getStatus(interactionId, transcriptId) | Interaction UUID + transcript UUID | Transcription status |
list(interactionId, request?) | Interaction UUID + optional filters | List of transcripts |
get(interactionId, transcriptId) | Interaction UUID + transcript UUID | Single transcript |
delete(interactionId, transcriptId) | Interaction UUID + transcript UUID | void |
Documents
Generate AI-produced clinical documents (e.g. SOAP notes) from interaction data.| Method | Parameters | Returns |
|---|---|---|
create(interactionId, request) | Interaction UUID + document generation options | Generated document |
list(interactionId) | Interaction UUID | List of documents |
get(interactionId, documentId) | Interaction UUID + document UUID | Single document |
update(interactionId, documentId, request?) | Interaction UUID + document UUID + update fields | Updated document |
delete(interactionId, documentId) | Interaction UUID + document UUID | void |
Facts
Extract structured clinical facts from text or manage facts on an interaction.| Method | Parameters | Returns |
|---|---|---|
extract(request) | Extraction options (context, output language) | Extracted facts |
list(interactionId) | Interaction UUID | List of facts |
create(interactionId, request) | Interaction UUID + fact definitions | Created facts |
batchUpdate(interactionId, request) | Interaction UUID + fact updates | Updated facts |
update(interactionId, factId, request?) | Interaction UUID + fact ID + update fields | Updated fact |
factGroupsList() | None | Available fact group definitions |
Templates
List and inspect document generation templates available to your tenant.JavaScript
| Method | Parameters | Returns |
|---|---|---|
list(request?) | Optional filters | List of templates |
get(key) | Template key string | Single template |
sectionList(request?) | Optional filters | List of template sections |
Codes
Predict medical codes from clinical data.JavaScript
| Method | Parameters | Returns |
|---|---|---|
predict(request) | Prediction options (text, code system) | Code predictions |
Agents
Create and interact with AI agents (Agentic Framework).| Method | Parameters | Returns |
|---|---|---|
list(request?) | Optional filters | List of agents |
create(request) | Agent definition | Created agent |
get(id) | Agent ID | Agent details |
getCard(id) | Agent ID | Agent card (A2A format) |
messageSend(id, request) | Agent ID + message payload | Agent response |
getTask(id, taskId, request?) | Agent ID + task ID | Task details |
getContext(id, contextId, request?) | Agent ID + context ID | Context details |
getRegistryExperts(request?) | Optional filters | Registry experts |
update(id, request?) | Agent ID + update fields | Updated agent |
delete(id) | Agent ID | void |
Stream
Real-time WebSocket connection for combined transcription, fact extraction, and more — tied to an interaction.connect parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Interaction UUID to attach the stream to |
configuration | Corti.StreamConfig | No | Stream configuration (transcription language, participants, mode). When provided, the SDK automatically sends the config message once the socket opens. If omitted, you must call sendConfiguration() yourself |
awaitConfiguration | boolean | No | When true (default), connect() waits for CONFIG_ACCEPTED before resolving. When false, returns the socket immediately and dispatches config errors as events |
proxy | ProxyOptions | No | Route through a proxy instead of connecting directly. Connects to the provided URL exactly as-is (no endpoint path is appended) |
debug | boolean | No | Enable debug logging |
reconnectAttempts | number | No | Number of reconnection attempts on disconnect |
tenantName and token automatically. If configuration is provided and awaitConfiguration is true, the promise rejects on CONFIG_DENIED or timeout.
Socket methods
| Method | Description |
|---|---|
on(event, handler) | Subscribe to events: "open", "message", "close", "error" |
off(event, handler?) | Remove an event handler |
sendAudio(data) | Send binary audio data (ArrayBuffer, Blob, or ArrayBufferView) |
sendFlush(message) | Request the server to flush buffered audio and return results |
sendEnd(message) | Signal end of audio stream |
sendConfiguration(message) | Send a configuration message (used internally by connect) |
send(data) | Send raw data directly on the underlying WebSocket |
close() | Close the connection and unregister event handlers. You should call sendEnd() first and wait for the ended message before closing — see Flush the Audio Buffer |
waitForOpen() | Returns a promise that resolves when the socket is open |
readyState | Current connection state (property, not method) |
Transcribe
Real-time WebSocket speech-to-text without an interaction context.JavaScript
connect parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
configuration | Corti.TranscribeConfig | No | Transcribe configuration (language, punctuation, commands). When provided, the SDK automatically sends the config message once the socket opens. If omitted, you must call sendConfiguration() yourself |
awaitConfiguration | boolean | No | When true (default), connect() waits for CONFIG_ACCEPTED before resolving. When false, returns the socket immediately and dispatches config errors as events |
proxy | ProxyOptions | No | Route through a proxy instead of connecting directly. Connects to the provided URL exactly as-is (no endpoint path is appended) |
debug | boolean | No | Enable debug logging |
reconnectAttempts | number | No | Number of reconnection attempts on disconnect |
sendAudio, sendFlush, sendEnd, close, etc.). The key differences are:
- No interaction ID — Transcribe operates standalone
- Different message types — Transcribe delivers
transcript,command,flushed,ended,usage, anderrormessages, while Stream deliverstranscript,facts,flushed,ended,usage, anderror
Auth
OAuth token management. In most cases you won’t call these directly — the SDK handles tokens automatically based on theauth option you pass to the constructor. These methods are useful for advanced scenarios like generating authorization URLs for browser-based flows.
| Method | Description |
|---|---|
getToken(request) | Get a token via client credentials |
getRopcFlowToken(request) | Get a token via ROPC flow |
getCodeFlowToken(request) | Exchange an authorization code for a token |
getPkceFlowToken(request) | Exchange a PKCE authorization code for a token |
refreshToken(request) | Refresh an expired token |
authorizeURL(options) | Generate an authorization code flow URL and redirect to it |
authorizePkceUrl(options) | Generate a PKCE flow redirect URL |
CortiAuth
A standalone authentication client for when you need OAuth token management without the fullCortiClient. Useful for proxy servers, custom backends, or applications that handle tokens separately from API calls.
JavaScript
Constructor options
| Option | Type | Required | Description |
|---|---|---|---|
environment | CortiEnvironment | CortiEnvironmentUrls | string | Yes | API region or custom URLs |
tenantName | string | Yes | Your Corti tenant name |
headers | Record<string, string> | No | Additional headers |
timeoutInSeconds | number | No | Request timeout |
maxRetries | number | No | Retry count |
Methods
All token methods accept an optionalscopes array. openid and profile are added automatically — pass additional scopes like "streams" or "transcribe" to get a scoped token.
| Method | Description | Returns |
|---|---|---|
getToken(request) | Get a token via client credentials | AuthTokenResponse |
getRopcFlowToken(request) | Get a token via ROPC flow | AuthTokenResponse |
getCodeFlowToken(request) | Exchange an authorization code for a token | AuthTokenResponse |
getPkceFlowToken(request) | Exchange a PKCE authorization code for a token | AuthTokenResponse |
refreshToken(request) | Refresh an expired token | AuthTokenResponse |
authorizeURL(options) | Generate an authorization code flow URL and redirect to it | string |
authorizePkceUrl(options) | Generate a PKCE flow redirect URL | string |
CortiAuth.getCodeVerifier() | Get the PKCE code verifier from the last authorizePkceUrl call (static) | string | null |
CortiWebSocketProxyClient
A lightweight client for WebSocket-only proxy scenarios. UnlikeCortiClient, it requires no environment, tenant, or authentication configuration — all routing is handled by the proxy option you pass at connect time.
JavaScript
Static properties
| Property | Type | Description |
|---|---|---|
stream | CustomProxyStream | Stream proxy client (transcription + facts, tied to an interaction) |
transcribe | CustomProxyTranscribe | Transcribe proxy client (standalone speech-to-text) |
stream.connect
| Parameter | Type | Required | Description |
|---|---|---|---|
proxy | ProxyOptions | Yes | Proxy URL, subprotocols, and query parameters. Connects to the provided URL exactly as-is (no endpoint path is appended) |
configuration | Corti.StreamConfig | No | Stream configuration (language, punctuation, etc.) |
awaitConfiguration | boolean | No | Wait for CONFIG_ACCEPTED before resolving (default true) |
debug | boolean | No | Enable debug logging |
reconnectAttempts | number | No | Number of reconnection attempts |
Promise<CustomStreamSocket> — same socket API as client.stream.connect.
transcribe.connect
| Parameter | Type | Required | Description |
|---|---|---|---|
proxy | ProxyOptions | Yes | Proxy URL, subprotocols, and query parameters. Connects to the provided URL exactly as-is (no endpoint path is appended) |
configuration | Corti.TranscribeConfig | No | Transcribe configuration (language, punctuation, etc.) |
awaitConfiguration | boolean | No | Wait for CONFIG_ACCEPTED before resolving (default true) |
debug | boolean | No | Enable debug logging |
reconnectAttempts | number | No | Number of reconnection attempts |
Promise<CustomTranscribeSocket> — same socket API as client.transcribe.connect.
ProxyOptions
The ProxyOptions type is also exported from @corti/sdk for use when typing proxy arguments in your own code.
JavaScript
| Property | Type | Required | Description |
|---|---|---|---|
url | string | Yes | WebSocket URL of your proxy server |
protocols | string[] | Record<string, string> | No | WebSocket subprotocols. Arrays are passed as-is; objects are encoded as [name, encodeURIComponent(value), ...] pairs |
queryParameters | Record<string, string> | No | Query parameters appended to the WebSocket URL |
Utilities
The@corti/sdk/utils sub-package exports helper functions for token inspection, environment resolution, and PKCE. These are useful in proxy servers, middleware, and custom authentication flows.
JavaScript
| Export | Description |
|---|---|
decodeToken(token) | Decode a Corti JWT to extract environment, tenantName, accessToken, and expiresAt. Returns null if the token is invalid or the issuer doesn’t match |
getEnvironment(env) | Normalize an environment string (e.g. "eu") or CortiEnvironment object into the internal URL format the SDK uses |
generateCodeVerifier() | Generate a PKCE code verifier (32 random bytes, base64url-encoded) |
generateCodeChallenge(verifier) | Compute the PKCE code challenge from a verifier (SHA-256, base64url-encoded). Returns a Promise |
DecodedToken | TypeScript type for the return value of decodeToken |