Skip to main content

Classes

AuthClient

Exchanges API-key credentials for a short-lived bearer access token. The token returned by createToken carries only the scopes you request and expires after expires_in seconds (typically 15 minutes). For hands-off token lifecycle management, prefer the top-level InterhumanClient, which uses a TokenManager to fetch and refresh tokens for you.

Constructors

Constructor
Parameters
Returns
AuthClient

Methods

createToken()
Mint an access token for the given credentials and scopes.
Parameters
Returns
Promise<TokenResponse>
Throws
when the credentials are invalid (401), lack a requested scope (403), or the request is otherwise rejected.
createClientToken()
Mint a short-lived, capped client token for direct browser use. Call this from your backend with your API key; the returned token is safe to hand to a browser to call the upload, stream, or realtime endpoints directly. It grants the requested scopes (default interhumanai.stream) and carries the caps you set, which the API enforces across upload, stream, and realtime (the video budget spans all three). Omitted fields are left unset (the server applies its defaults, e.g. a single concurrent session and a 300s TTL).
Parameters
Returns
Promise<ClientTokenResponse>
Throws
when the credentials are invalid (401), the key lacks a requested scope (403), or the mint rate limit is exceeded (429).
revokeClientToken()
Revoke a previously minted client token. Call this from your backend with the same API key that minted the token. Once revoked, the token is rejected on new requests and any live streaming session it opened is torn down on its next chunk. Revoking an already-expired token is a harmless no-op.
Parameters
Returns
Promise<void>
Throws
when the credentials or token are invalid (401).

StaticTokenProvider

A TokenProvider that always returns the same pre-issued token.

Implements

Constructors

Constructor
Parameters
Returns
StaticTokenProvider

Methods

getToken()
Return a currently-valid bearer token, minting/refreshing as needed.
Returns
Promise<string>
Implementation of
TokenProvider.getToken

TokenManager

Mints access tokens from API-key credentials via AuthClient and caches them until shortly before they expire, so callers can request a valid bearer token cheaply on every call. Concurrent requests while a token is being minted share a single in-flight request.

Implements

Constructors

Constructor
Parameters
Returns
TokenManager

Methods

getToken()
Return a valid bearer token, minting or refreshing transparently.
Returns
Promise<string>
Implementation of
TokenProvider.getToken
invalidate()
Drop any cached token so the next getToken mints a fresh one.
Returns
void

InterhumanClient

The main entry point. Construct it once with credentials (or a token) and use upload, stream, and realtime to call the API; token lifecycle is handled for you.

Example

Constructors

Constructor
Parameters
Returns
InterhumanClient

Properties

Methods

stream()
Create a new StreamClient for a live analysis session. Each call returns a fresh client (one per WebSocket session); register handlers and then call connect(). By default the session opens WS /v1/stream/analyze (Inter-1). Pass { apiVersion: "v2" } to open WS /v2/stream/analyze and have the same session analyzed by the Inter-2 model — the protocol, handlers and types are identical.
Parameters
Returns
StreamClient
realtime()
Create a new RealtimeClient for a realtime multi-track analysis session (WS /v0/realtime/analyze). Each call returns a fresh client (one per WebSocket session); register handlers and then call connect(). The endpoint requires tokens holding the realtime scope, which is not in the client’s default scopes, so pass it explicitly (e.g. scopes: [Scope.Upload, Scope.Stream, Scope.Realtime]). Request every scope the client needs: the minted token grants exactly what was asked for, so narrowing to [Scope.Realtime] alone closes off upload() and stream().
Returns
RealtimeClient
getToken()
Return a currently-valid bearer token (minting/refreshing as needed).
Returns
Promise<string>

InterhumanError

Base class for every error the SDK throws.

Extends

  • Error

Extended by

Constructors

Constructor
Parameters
Returns
InterhumanError
Overrides

InterhumanApiError

An error response from an HTTP endpoint (/v1/auth, /v1/upload/analyze). errorId, correlationId, and link are surfaced from the canonical ApiErrorBody when the server returned one.

Extends

Constructors

Constructor
Parameters
Returns
InterhumanApiError
Overrides
InterhumanError.constructor

Properties


UploadJobTimeoutError

An upload job did not reach a terminal state within the wait the caller allowed (UploadClient.waitForJob with timeoutMs). The job itself keeps running; job is the last envelope read, so the caller can keep polling with its job_id.

Extends

Constructors

Constructor
Parameters
Returns
UploadJobTimeoutError
Overrides
InterhumanError.constructor

Properties


InterhumanConfigError

A configuration/usage error caught before any network call. Stream error envelopes are not thrown — they are delivered as typed StreamErrorEvents through the stream client’s on("error", …) surface, and transport-level socket failures arrive on "socketError" as a base InterhumanError.

Extends

Constructors

Constructor
Parameters
Returns
InterhumanConfigError
Inherited from
InterhumanError.constructor

RealtimeClient

A typed client over the realtime WebSocket protocol. The realtime endpoint shares the stream endpoint’s session mechanics (subprotocol bearer auth, binary video frames, JSON envelopes down, and the requestClose() graceful shutdown handshake) and adds multi-track analysis, a caller-supplied transcript (sendTranscript), and a periodic recommendation step (realtime_recommendation.generated) enabled through the session config’s realtime_recommendation_instructions. The endpoint currently ships under the v0 path (/v0/realtime/analyze), which may change when it graduates to v1, and requires credentials holding the interhumanai.realtime scope.

Example

Extends

Constructors

Constructor
Parameters
Returns
RealtimeClient
Overrides
SessionSocketClient.constructor

Properties

Accessors

isOpen
Get Signature
Whether the underlying socket is open.
Returns
boolean
Inherited from
SessionSocketClient.isOpen

Methods

sendTranscript()
Send (or replace) the caller-supplied transcript as a transcript.updated text frame. The most recent transcript replaces any prior one for the session and is rendered into the recommendation prompt. A transcript that does not match the segment shape is rejected by the server with a non-fatal error envelope; the session stays open.
Parameters
Returns
void
on()
Subscribe to an event. Returns an unsubscribe function. Use a specific envelope type (e.g. "signal.detected"), "message" for every envelope, or a lifecycle event ("open", "close", "socketError").
Type Parameters
Parameters
Returns
() => void
Inherited from
SessionSocketClient.on
off()
Unsubscribe a previously registered handler.
Type Parameters
Parameters
Returns
void
Inherited from
SessionSocketClient.off
once()
Subscribe to the next occurrence of an event, then auto-unsubscribe.
Type Parameters
Parameters
Returns
() => void
Inherited from
SessionSocketClient.once
connect()
Open the connection and resolve once it is established. Rejects if the connection closes or errors before opening (e.g. invalid credentials).
Returns
Promise<void>
Inherited from
SessionSocketClient.connect
waitForSessionReady()
Wait for the session.ready envelope. Resolves immediately if it has already arrived (the envelope is retained), otherwise on the next one. Safe to call after connect without racing the frame. Rejects with an InterhumanError if the connection closes before the session becomes ready — including when the server accepts the handshake and then refuses the session, which it reports as an error envelope followed by a close (for example ih1003 when the endpoint’s backend is not configured). The message names the endpoint, the close code and reason, and that error envelope when there was one. A call made after such a close rejects immediately rather than waiting forever. Because the promise rejects rather than hanging, every caller must handle the rejection: a caller that races it against a timeout, or requests it before connect and awaits connect() first, should attach a .catch() so a refused session is not an unhandled rejection.
Returns
Promise<RealtimeSessionReadyEvent>
Inherited from
SessionSocketClient.waitForSessionReady
sendVideo()
Send a chunk of WebM or fragmented-MP4 video as a binary frame.
Parameters
Returns
void
Inherited from
SessionSocketClient.sendVideo
sendBinary()
Send an arbitrary binary frame.
Parameters
Returns
void
Inherited from
SessionSocketClient.sendBinary
updateConfig()
Send (or replace) the session config. Each frame fully replaces the active config; the server acknowledges with a session.updated envelope.
Parameters
Returns
void
Inherited from
SessionSocketClient.updateConfig
requestClose()
Request a graceful end-of-analysis shutdown (session.close). The server acknowledges with a session.closing envelope whose data.max_drain_seconds is the longest you should wait for the final session.ended envelope. After the acknowledgment the server rejects new video, finishes analyzing the video it already accepted (emitting the normal envelopes in order, plus signal.ended for still-active signals), sends session.ended, and closes the socket with code 1000 — so listen for "session.ended" (or "close") rather than calling close.
Returns
void
Inherited from
SessionSocketClient.requestClose
close()
Close the connection immediately, without the graceful drain handshake.
Parameters
Returns
void
Inherited from
SessionSocketClient.close
sendJson()
Send an arbitrary JSON payload as a text frame.
Parameters
Returns
void
Inherited from
SessionSocketClient.sendJson

abstract SessionSocketClient

Base class implementing the shared live-session WebSocket protocol. Authentication uses the Sec-WebSocket-Protocol: access_token, <token> subprotocol pair, which is portable across browsers and Node (the standard WebSocket constructor cannot set an Authorization header). Inbound frames are decoded into the protocol’s envelope union and dispatched through the typed on surface; outbound video is sent as binary frames and JSON payloads (session config, and for realtime the transcript) as text frames.

Extended by

Type Parameters

Constructors

Constructor
Parameters
Returns
SessionSocketClient<TEventMap, TConfig>

Properties

Accessors

isOpen
Get Signature
Whether the underlying socket is open.
Returns
boolean

Methods

on()
Subscribe to an event. Returns an unsubscribe function. Use a specific envelope type (e.g. "signal.detected"), "message" for every envelope, or a lifecycle event ("open", "close", "socketError").
Type Parameters
Parameters
Returns
() => void
off()
Unsubscribe a previously registered handler.
Type Parameters
Parameters
Returns
void
once()
Subscribe to the next occurrence of an event, then auto-unsubscribe.
Type Parameters
Parameters
Returns
() => void
connect()
Open the connection and resolve once it is established. Rejects if the connection closes or errors before opening (e.g. invalid credentials).
Returns
Promise<void>
waitForSessionReady()
Wait for the session.ready envelope. Resolves immediately if it has already arrived (the envelope is retained), otherwise on the next one. Safe to call after connect without racing the frame. Rejects with an InterhumanError if the connection closes before the session becomes ready — including when the server accepts the handshake and then refuses the session, which it reports as an error envelope followed by a close (for example ih1003 when the endpoint’s backend is not configured). The message names the endpoint, the close code and reason, and that error envelope when there was one. A call made after such a close rejects immediately rather than waiting forever. Because the promise rejects rather than hanging, every caller must handle the rejection: a caller that races it against a timeout, or requests it before connect and awaits connect() first, should attach a .catch() so a refused session is not an unhandled rejection.
Returns
Promise<TEventMap["session.ready"]>
sendVideo()
Send a chunk of WebM or fragmented-MP4 video as a binary frame.
Parameters
Returns
void
sendBinary()
Send an arbitrary binary frame.
Parameters
Returns
void
updateConfig()
Send (or replace) the session config. Each frame fully replaces the active config; the server acknowledges with a session.updated envelope.
Parameters
Returns
void
requestClose()
Request a graceful end-of-analysis shutdown (session.close). The server acknowledges with a session.closing envelope whose data.max_drain_seconds is the longest you should wait for the final session.ended envelope. After the acknowledgment the server rejects new video, finishes analyzing the video it already accepted (emitting the normal envelopes in order, plus signal.ended for still-active signals), sends session.ended, and closes the socket with code 1000 — so listen for "session.ended" (or "close") rather than calling close.
Returns
void
close()
Close the connection immediately, without the graceful drain handshake.
Parameters
Returns
void
sendJson()
Send an arbitrary JSON payload as a text frame.
Parameters
Returns
void

StreamClient

A typed client over the stream WebSocket protocol. Authentication uses the Sec-WebSocket-Protocol: access_token, <token> subprotocol pair, which is portable across browsers and Node (the standard WebSocket constructor cannot set an Authorization header). Inbound frames are decoded into the StreamEvent union and dispatched through the typed on surface inherited from SessionSocketClient; outbound video is sent as binary frames and session config as a JSON text frame. The client serves both stream endpoints — /v1/stream/analyze (Inter-1, the default) and /v2/stream/analyze (Inter-2) — selected by StreamClientOptions.apiVersion. The protocol is the same on both, and each names the endpoint it actually opened in the errors it raises: a v2 session reports the Inter-2 stream, a v1 session the Stream. On /v2/stream/analyze the model is a permission of its own: the credential must carry interhumanai.stream.<model> for the model the session opens on, named by StreamClientOptions.model (default "inter-2"). session.ready lists, under supported_session_config_options.model, the models the deployment serves that the credential may select, and a later updateConfig({ model }) switching to one the credential lacks is answered with a non-fatal error envelope (ih2003) while the session continues on its current model. Add an audio_format on "inter-2-audio" to stream raw PCM frames with sendAudio instead of container media.

Examples

Extends

Constructors

Constructor
Parameters
Returns
StreamClient
Overrides
SessionSocketClient.constructor

Properties

Accessors

isOpen
Get Signature
Whether the underlying socket is open.
Returns
boolean
Inherited from
SessionSocketClient.isOpen

Methods

on()
Subscribe to an event. Returns an unsubscribe function. Use a specific envelope type (e.g. "signal.detected"), "message" for every envelope, or a lifecycle event ("open", "close", "socketError").
Type Parameters
Parameters
Returns
() => void
Inherited from
SessionSocketClient.on
off()
Unsubscribe a previously registered handler.
Type Parameters
Parameters
Returns
void
Inherited from
SessionSocketClient.off
once()
Subscribe to the next occurrence of an event, then auto-unsubscribe.
Type Parameters
Parameters
Returns
() => void
Inherited from
SessionSocketClient.once
connect()
Open the connection and resolve once it is established. Rejects if the connection closes or errors before opening (e.g. invalid credentials).
Returns
Promise<void>
Inherited from
SessionSocketClient.connect
waitForSessionReady()
Wait for the session.ready envelope. Resolves immediately if it has already arrived (the envelope is retained), otherwise on the next one. Safe to call after connect without racing the frame. Rejects with an InterhumanError if the connection closes before the session becomes ready — including when the server accepts the handshake and then refuses the session, which it reports as an error envelope followed by a close (for example ih1003 when the endpoint’s backend is not configured). The message names the endpoint, the close code and reason, and that error envelope when there was one. A call made after such a close rejects immediately rather than waiting forever. Because the promise rejects rather than hanging, every caller must handle the rejection: a caller that races it against a timeout, or requests it before connect and awaits connect() first, should attach a .catch() so a refused session is not an unhandled rejection.
Returns
Promise<SessionReadyEvent>
Inherited from
SessionSocketClient.waitForSessionReady
sendVideo()
Send a chunk of WebM or fragmented-MP4 video as a binary frame.
Parameters
Returns
void
Inherited from
SessionSocketClient.sendVideo
sendBinary()
Send an arbitrary binary frame.
Parameters
Returns
void
Inherited from
SessionSocketClient.sendBinary
updateConfig()
Send (or replace) the session config. Each frame fully replaces the active config; the server acknowledges with a session.updated envelope.
Parameters
Returns
void
Inherited from
SessionSocketClient.updateConfig
requestClose()
Request a graceful end-of-analysis shutdown (session.close). The server acknowledges with a session.closing envelope whose data.max_drain_seconds is the longest you should wait for the final session.ended envelope. After the acknowledgment the server rejects new video, finishes analyzing the video it already accepted (emitting the normal envelopes in order, plus signal.ended for still-active signals), sends session.ended, and closes the socket with code 1000 — so listen for "session.ended" (or "close") rather than calling close.
Returns
void
Inherited from
SessionSocketClient.requestClose
close()
Close the connection immediately, without the graceful drain handshake.
Parameters
Returns
void
Inherited from
SessionSocketClient.close
sendJson()
Send an arbitrary JSON payload as a text frame.
Parameters
Returns
void
Inherited from
SessionSocketClient.sendJson
sendAudio()
Send one frame of raw PCM audio as a binary frame. Only meaningful on apiVersion: "v2" after the session config declared an audio_format with model: "inter-2-audio"; the server then reads every binary frame as signed 16-bit mono PCM at the declared sample rate. Frames can be any size and cut at any byte boundary. Without that declaration a binary frame is container media, which sendVideo names.
Parameters
Returns
void

UploadClient

Analyzes complete files. analyze is the v1 route: the file is analyzed inside the request and the report comes back with the response. submit, getJob and waitForJob are the v2 job routes: a file is accepted as a job, analyzed by an Inter-2 model after the response, and read back by id until it is completed or failed. Every request is sent with the bearer token attached automatically from the configured TokenProvider.

Constructors

Constructor
Parameters
Returns
UploadClient

Methods

analyze()
Analyze a video file in upload mode.
Parameters
Returns
Promise<AnalysisResult>
Throws
on a rejected request (auth, validation, too-large/too-short media, quota, unprocessable video, server error).
submit()
Submit a file to POST /v2/upload/analyze as an asynchronous job. The API validates the file and answers with the job envelope before the analysis runs. With waitSeconds above zero the request is held open for up to that long, and the envelope comes back terminal (result or error set) when the job finished in time; otherwise it comes back queued or running, and waitForJob or getJob reads it later. Check status rather than assuming either.
Parameters
Returns
Promise<UploadJob>
Throws
on a rejected submit: ih4020 for a model the route does not serve yet, ih5008 for a file with no audio stream, ih4002 for an unsupported container, ih4007 for media under 3 s, ih1003 when no backend serves the model on the deployment, and the usual auth, size and quota errors.
getJob()
Read a job’s current envelope from GET /v2/upload/jobs/{job_id}.
Parameters
Returns
Promise<UploadJob>
Throws
ih4021 (404) when the id is unknown to this account or the job has expired, among the usual errors.
waitForJob()
Poll a job until it is completed or failed, and resolve with it. A terminal envelope passed in resolves at once without a request. A failed job resolves, not rejects: read its error.
Parameters
Returns
Promise<UploadJob>
Throws
when timeoutMs elapses first. The job keeps running; the error carries the last envelope read.

Interfaces

AuthClientOptions

Options for constructing an AuthClient.

Properties


TokenProvider

Anything that can supply a bearer token on demand.

Methods

getToken()
Return a currently-valid bearer token, minting/refreshing as needed.
Returns
Promise<string>

TokenManagerOptions

Options for a TokenManager.

Properties


ApiKeyCredentials

Credentials issued in the Interhuman customer platform.

Extended by

Properties


ApiKeyCredential

A full API key string used to mint and revoke client tokens.

Extended by

Properties


TokenRequest

Request body for POST /v1/auth.

Extends

Properties


TokenResponse

Response body from POST /v1/auth.

Properties


ClientTokenRequest

Request for minting an ephemeral, capped client token (POST /v1/client_tokens). Call this server-side with your API key; the returned token is safe to hand to a browser to call the upload, stream, or realtime endpoints directly. Every cap is optional. The token grants only the requested scopes (default interhumanai.stream); the caps are enforced on streaming sessions (stream / realtime) and the video budget additionally spans upload.

Extends

Properties


ClientTokenResponse

Response body from POST /v1/client_tokens.

Properties


RevokeClientTokenRequest

Request for revoking a client token (POST /v1/client_tokens/revoke).

Extends

Properties


InterhumanClientOptions

Options for constructing an InterhumanClient.

Properties


StreamOptions

Per-session options for InterhumanClient.stream.

Properties


ApiErrorBody

The canonical error body returned by every HTTP error path.

Properties


TranscriptSegment

One diarized utterance of a realtime transcript, as sent with sendTranscript.

Properties


RealtimeSessionConfig

Client-to-server realtime session config (sent as a JSON text frame). The last config sent fully replaces the active one; the server acknowledges with a session.updated envelope. The stream include flags are not accepted — the realtime endpoint never emits the conversation-quality or engagement updates those flags control.

Properties


TranscriptUpdatedFrame

The inbound transcript.updated text frame carrying a caller-supplied transcript. Sent by RealtimeClient.sendTranscript; the most recent transcript replaces any prior one and is rendered into the recommendation prompt.

Properties


RealtimeSessionReadyConfigOptions

Supported realtime session-config options advertised on session.ready. Unlike the stream options, only the realtime controls appear here — never the stream include / goal_dimensions options.

Properties


RealtimeSessionReadyData

session.ready payload — the same connection-level limits as the stream session.ready, with the realtime supported-config options.

Properties


RealtimeSessionReadyEvent

Fields shared by every server→client envelope.

Extends

Properties


RealtimeSessionUpdatedData

session.updated payload — the consolidated realtime config after a config frame applied. Reports only the realtime options, never the stream-only include / goal_dimensions fields.

Properties


RealtimeSessionUpdatedEvent

Fields shared by every server→client envelope.

Extends

Properties


RealtimeRecommendationGeneratedData

realtime_recommendation.generated payload — one recommendation run’s guidance text.

Properties


RealtimeRecommendationGeneratedEvent

realtime_recommendation.generated — the periodic recommendation result. Emitted only when realtime_recommendation_instructions has enabled recommendation, paced by realtime_recommendation_frequency.

Extends

Properties


RealtimeSignalDetectedData

Properties


RealtimeSignalDetectedEvent

A social signal was detected. The realtime payload carries no rationale.

Extends

Properties


RealtimeSignalUpdatedData

Properties


RealtimeSignalUpdatedEvent

An active signal’s details changed. The realtime payload carries no rationale.

Extends

Properties


RealtimeEventMap

Event payloads keyed by event name, for the typed on/off surface of the realtime client. The envelope types map to their envelope objects; the remaining keys are client-level lifecycle events.

Properties


SessionSocketClientOptions

Options shared by every WebSocket session client.

Extended by

Properties


SessionSocketEventMapBase

The lifecycle and wildcard events every session event map carries, alongside its protocol-specific envelope type keys. TEvent is the protocol’s envelope union and TReady its session.ready envelope.

Type Parameters

Properties


StreamClientOptions

Options for constructing a StreamClient.

Extends

Properties


StreamEnvelopeBase

Fields shared by every server→client envelope.

Extended by

Properties


RawAudioFormat

Declares that a session’s binary frames are raw audio rather than container media: signed 16-bit little-endian PCM at sample_rate, mono, with no header, cut at any byte boundary. Only "inter-2-audio" accepts it.

Properties


SessionReadyConfigOptions

Supported session-config options advertised on session.ready.

Properties


SessionReadyData

session.ready payload — session limits and supported config.

Properties


SessionReadyEvent

Fields shared by every server→client envelope.

Extends

Properties


SessionUpdatedData

session.updated payload — consolidated config after a config frame applied.

Properties


SessionUpdatedEvent

Fields shared by every server→client envelope.

Extends

Properties


SessionClosingData

session.closing payload — the graceful-close drain contract.

Properties


SessionClosingEvent

Acknowledges a caller-initiated session.close request. From this point the server rejects new video, finishes analyzing the video it already accepted, emits final lifecycle envelopes (signal.ended for still-active signals), sends session.ended, and closes the socket.

Extends

Properties


SessionEndedData

session.ended payload — why the session ended.

Properties


SessionEndedEvent

The final message of a gracefully closed session: all analysis is closed and the server closes the WebSocket (code 1000) immediately after sending it. No further analysis messages follow.

Extends

Properties


SignalDetectedData

Properties


SignalDetectedEvent

Fields shared by every server→client envelope.

Extends

Properties


SignalUpdatedData

Properties


SignalUpdatedEvent

Fields shared by every server→client envelope.

Extends

Properties


SignalEndedData

Properties


SignalEndedEvent

Fields shared by every server→client envelope.

Extends

Properties


EngagementUpdatedData

Properties


EngagementUpdatedEvent

Fields shared by every server→client envelope.

Extends

Properties


ConversationQualityUpdatedData

Properties


ConversationQualityUpdatedEvent

Fields shared by every server→client envelope.

Extends

Properties


FeedbackGeneratedData

Properties


FeedbackGeneratedEvent

Fields shared by every server→client envelope.

Extends

Properties


CoverageDroppedRange

A contiguous range of session time no analysis covered (not billed).

Properties


CoverageDroppedData

Payload of CoverageDroppedEvent: the time ranges no analysis covers. Emitted when the analysis pipeline sheds buffered video under backpressure, and when the incoming stream itself skipped ahead — a client stall whose media never arrived while its recorder clock kept running. Either way the listed ranges were never analyzed and are not billed.

Properties


CoverageDroppedEvent

Fields shared by every server→client envelope.

Extends

Properties


CoverageDegradedRange

One time range whose visual coverage was partial, in session seconds.

Properties


CoverageDegradedData

Payload of CoverageDegradedEvent: the affected time ranges plus the reason. Unlike coverage.dropped, these windows were analyzed (audio plus whatever video decoded) and are billed normally — only the visual coverage was partial.

Properties


CoverageDegradedEvent

Informational notice that one or more analysis windows were analyzed with partial visual coverage. The session stays open and the windows are billed normally; the ranges tell your application that visual signals over that stretch drew on partial video.

Extends

Properties


StreamErrorData

Properties


StreamErrorEvent

Fields shared by every server→client envelope.

Extends

Properties


StreamSessionConfig

Client-to-server session config (sent as a JSON text frame).

Properties


SessionCloseRequest

Client-to-server graceful close request (sent as a JSON text frame). Tells the server the caller is done sending video; the server acknowledges with session.closing and ends the session with session.ended.

Properties


StreamCloseInfo

Information about a closed stream connection.

Properties


StreamEventMap

Event payloads keyed by event name, for the typed on/off surface. The twelve envelope types map to their envelope objects; the remaining keys are client-level lifecycle events.

Properties


WebSocketLike

The subset of the WHATWG WebSocket interface the SDK relies on. Both the browser WebSocket and Node 22+‘s global WebSocket satisfy this.

Properties

Methods

send()
Parameters
Returns
void
close()
Parameters
Returns
void
addEventListener()
Parameters
Returns
void
removeEventListener()
Parameters
Returns
void

Signal

A single social signal detected over a span of the analyzed media.

Properties


EngagementStateEntry

A contiguous stretch of media labeled with a single engagement state.

Properties


ConversationQualityValues

The five conversation-quality dimension scores plus their mean (0–100).

Properties


ConversationQualityTimelineEntry

Conversation-quality scores for one window of the timeline.

Properties


ConversationQuality

Overall and time-varying conversation-quality scores.

Properties


InteractionFeedback

Structured interaction feedback returned by the coach model.

Properties


AnalysisResult

The full report returned by POST /v1/upload/analyze.

Properties


AnalyzeUploadInput

Arguments for UploadClient.analyze.

Properties


UploadJobWindow

The analysis of one fixed-length window of an upload job’s file. Each signal carries the window’s span as its start and end, and its modality names the evidence the model read (["audio"] for inter-2-audio).

Properties


UploadJobResult

The result of a completed upload job: one entry per analyzed window.

Properties


UploadJobError

Why an upload job failed, in the API’s standard error-body shape.

Properties


UploadJob

The job envelope returned by POST /v2/upload/analyze and GET /v2/upload/jobs/{job_id}. result is set only when status is completed; error only when it is failed.

Properties


SubmitUploadJobInput

Arguments for UploadClient.submit.

Properties


WaitForJobOptions

Options for UploadClient.waitForJob.

Properties


UploadClientOptions

Options for constructing an UploadClient.

Properties

Type Aliases

Environment

A named Interhuman API environment.

RealtimeClientOptions

Options for constructing a RealtimeClient.

AnalysisGroup

Top-level analysis surfaces a realtime session can run. Each group maps to one or more server-side analysis tracks: visual is the visual-signals track and audio the audio tracks.

RealtimeRecommendationFrequency

How often the recommendation step runs, measured in analyzed video: high = every 10 seconds, medium = every 20 seconds, low = every 30 seconds. Only takes effect once realtime_recommendation_instructions has enabled recommendation.

RealtimeEvent

Discriminated union of every realtime server→client envelope.

VideoChunk

A chunk of WebM or fragmented-MP4 video to stream to the server.

AudioFrame

A frame of raw PCM audio to stream to the server.

Listener

An event handler registered via on/once.

Type Parameters

Parameters

Returns

void

StreamApiVersion

Which stream endpoint a StreamClient opens.
  • "v1"WS /v1/stream/analyze, analyzed by the Inter-1 model.
  • "v2"WS /v2/stream/analyze, analyzed by the Inter-2 model.
The two endpoints share one protocol: the same authentication, the same session.ready limits and session config, the same video framing, and the same server→client envelopes in the same order. Only the model behind the analysis differs, so the same client, handlers and types serve both.

StreamModel

Inter-2 models a WS /v2/stream/analyze session can select through its session config.
  • "inter-2" (the default) reads the video.
  • "inter-2-audio" hears the audio alone: an audio-only recording is accepted, the video of a recording that carries one is dropped, and raw PCM frames are accepted once an RawAudioFormat is declared.
  • "inter-2-deep" is an upload model; naming it on the stream is refused.
WS /v1/stream/analyze offers no selection and rejects any value.

PcmSampleRate

Sample rates accepted for raw PCM frames.

StreamEvent

Discriminated union of every server→client envelope.

WebSocketFactory

Constructs a WebSocketLike from a URL and optional subprotocols.

Parameters

Returns

WebSocketLike

ScopeValue

OAuth-style scopes an API key can carry. A scope names one operation, or one (operation, model) cell of the Inter-2 routes: the bare interhumanai.upload and interhumanai.stream are the Inter-1 cells, and interhumanai.<operation>.<model> is one model on the matching /v2 route. No scope implies another, and there is no interhumanai.stream.inter-2-deep: Deep is an upload-only model.

SignalType

Social signal types the model can detect. tension and frustration name the same underlying negative state but keep the detecting source legible: tension comes only from the Realtime API’s visual track, while frustration comes from every other source (Inter-1, the realtime audio track, and the upload and stream endpoints).

Probability

Confidence level attached to a detected signal.

EngagementLevel

Engagement state of the analyzed subject.

GoalDimension

Conversation-quality dimensions a caller can flag as a session goal.

IncludeFlag

Optional response sections the caller may request.

FeedbackType

Discriminator for the structured interaction-feedback result.

VideoInput

The video to analyze. Either a Blob/File (browsers, or Node 18+ where Blob is global) or raw bytes plus a filename.

Union Members

Blob
Type Literal
data
Raw video bytes.
filename?
Filename to report in the multipart part, e.g. "clip.mp4".
contentType?
MIME type, e.g. "video/mp4".

UploadModel

Inter-2 models a POST /v2/upload/analyze job can name. inter-2-audio is served today. inter-2 and inter-2-deep are valid values the route does not serve yet; submitting them rejects with an InterhumanApiError whose errorId is ih4020.

UploadJobStatus

Lifecycle of a POST /v2/upload/analyze job. queued and running are transient; completed and failed are terminal, and the job stays readable until its expires_at.

Variables

HTTP_BASE_URLS

HTTP base URLs per named environment.

AnalysisGroup

Named analysis-group constants.

Type Declaration

Visual
The visual-signals track.
Audio
The audio tracks.

RealtimeRecommendationFrequency

Named recommendation-frequency constants.

Type Declaration

High
A recommendation runs every 10 seconds of analyzed video.
Medium
A recommendation runs every 20 seconds of analyzed video.
Low
A recommendation runs every 30 seconds of analyzed video.

SDK_NAME

This SDK’s canonical name in API telemetry.

SDK_VERSION

This SDK’s package version, read from package.json at build time so there is no second version literal to keep in sync.

SDK_HEADER_NAME

HTTP header carrying the SDK identity.

STREAM_ENDPOINT_PATHS

Endpoint path opened for each StreamApiVersion.

StreamModel

Named stream-model constants.

Type Declaration

Inter2
Inter2Audio
Inter2Deep

WS_READY_STATE

readyState constants, mirrored from the WHATWG WebSocket spec.

Type Declaration

CONNECTING
OPEN
CLOSING
CLOSED

Scope

Named scope constants.

Type Declaration

Upload
Grants access to POST /v1/upload/analyze (Inter-1).
Stream
Grants access to WS /v1/stream/analyze (Inter-1).
Realtime
Grants access to WS /v0/realtime/analyze.
UploadInter2
Grants POST /v2/upload/analyze with model: "inter-2", and reading the account’s jobs.
UploadInter2Audio
Grants POST /v2/upload/analyze with model: "inter-2-audio", and reading the account’s jobs.
UploadInter2Deep
Grants POST /v2/upload/analyze with model: "inter-2-deep", and reading the account’s jobs.
StreamInter2
Grants WS /v2/stream/analyze with model: "inter-2".
StreamInter2Audio
Grants WS /v2/stream/analyze with model: "inter-2-audio".

GoalDimension

Named goal-dimension constants.

Type Declaration

Clarity
Authority
Energy
Rapport
Learning

IncludeFlag

Named include-flag constants.

Type Declaration

ConversationQualityOverall
ConversationQualityTimeline

UploadModel

Named upload-model constants.

Type Declaration

Inter2
Inter2Audio
Inter2Deep

DEFAULT_JOB_POLL_INTERVAL_MS

Default interval between status reads in UploadClient.waitForJob.

Functions

resolveHttpBaseUrl()

Resolve the HTTP base URL for a client. baseUrl takes precedence (use it to point at a local server, e.g. http://localhost:8080); otherwise the named environment is used, defaulting to production. The returned URL never has a trailing slash.

Parameters

Returns

string

httpToWsBaseUrl()

Derive the WebSocket origin from an HTTP base URL: httpswss, httpws. Any path on the base URL is preserved (so a proxy mount point survives), with the trailing slash trimmed.

Parameters

Returns

string

sdkHeaderValue()

The X-Interhuman-SDK value this SDK sends: typescript/<version>.

Returns

string

isTerminal()

Whether a job has finished, successfully or not.

Parameters

Returns

boolean