> ## Documentation Index
> Fetch the complete documentation index at: https://beta.interhuman.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript SDK

> API reference for @interhumanai/sdk — the official TypeScript client for auth, upload, and stream.

## Classes

### AuthClient

Exchanges API-key credentials for a short-lived bearer access token.

The token returned by [createToken](#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](#interhumanclient), which uses a [TokenManager](#tokenmanager) to fetch and
refresh tokens for you.

#### Constructors

##### Constructor

```ts theme={null}
new AuthClient(options?): AuthClient;
```

###### Parameters

| Parameter | Type                                      |
| --------- | ----------------------------------------- |
| `options` | [`AuthClientOptions`](#authclientoptions) |

###### Returns

[`AuthClient`](#authclient)

#### Methods

##### createToken()

```ts theme={null}
createToken(request): Promise<TokenResponse>;
```

Mint an access token for the given credentials and scopes.

###### Parameters

| Parameter | Type                            |
| --------- | ------------------------------- |
| `request` | [`TokenRequest`](#tokenrequest) |

###### Returns

`Promise`\<[`TokenResponse`](#tokenresponse)>

###### Throws

when the credentials are invalid (401), lack a
requested scope (403), or the request is otherwise rejected.

##### createClientToken()

```ts theme={null}
createClientToken(request): Promise<ClientTokenResponse>;
```

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

| Parameter | Type                                        |
| --------- | ------------------------------------------- |
| `request` | [`ClientTokenRequest`](#clienttokenrequest) |

###### Returns

`Promise`\<[`ClientTokenResponse`](#clienttokenresponse)>

###### Throws

when the credentials are invalid (401), the key
lacks a requested scope (403), or the mint rate limit is exceeded (429).

##### revokeClientToken()

```ts theme={null}
revokeClientToken(request): Promise<void>;
```

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

| Parameter | Type                                                    |
| --------- | ------------------------------------------------------- |
| `request` | [`RevokeClientTokenRequest`](#revokeclienttokenrequest) |

###### Returns

`Promise`\<`void`>

###### Throws

when the credentials or token are invalid (401).

***

### StaticTokenProvider

A [TokenProvider](#tokenprovider) that always returns the same pre-issued token.

#### Implements

* [`TokenProvider`](#tokenprovider)

#### Constructors

##### Constructor

```ts theme={null}
new StaticTokenProvider(token): StaticTokenProvider;
```

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `token`   | `string` |

###### Returns

[`StaticTokenProvider`](#statictokenprovider)

#### Methods

##### getToken()

```ts theme={null}
getToken(): Promise<string>;
```

Return a currently-valid bearer token, minting/refreshing as needed.

###### Returns

`Promise`\<`string`>

###### Implementation of

[`TokenProvider`](#tokenprovider).[`getToken`](#gettoken)

***

### TokenManager

Mints access tokens from API-key credentials via [AuthClient](#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

* [`TokenProvider`](#tokenprovider)

#### Constructors

##### Constructor

```ts theme={null}
new TokenManager(options): TokenManager;
```

###### Parameters

| Parameter | Type                                          |
| --------- | --------------------------------------------- |
| `options` | [`TokenManagerOptions`](#tokenmanageroptions) |

###### Returns

[`TokenManager`](#tokenmanager)

#### Methods

##### getToken()

```ts theme={null}
getToken(): Promise<string>;
```

Return a valid bearer token, minting or refreshing transparently.

###### Returns

`Promise`\<`string`>

###### Implementation of

[`TokenProvider`](#tokenprovider).[`getToken`](#gettoken)

##### invalidate()

```ts theme={null}
invalidate(): void;
```

Drop any cached token so the next [getToken](#gettoken-2) mints a fresh one.

###### Returns

`void`

***

### InterhumanClient

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

#### Example

```ts theme={null}
const client = new InterhumanClient({
  credentials: { keyId: "...", keySecret: "..." },
});
const report = await client.upload.analyze({ file: bytes, filename: "clip.mp4" });
```

#### Constructors

##### Constructor

```ts theme={null}
new InterhumanClient(options): InterhumanClient;
```

###### Parameters

| Parameter | Type                                                  |
| --------- | ----------------------------------------------------- |
| `options` | [`InterhumanClientOptions`](#interhumanclientoptions) |

###### Returns

[`InterhumanClient`](#interhumanclient)

#### Properties

| Property                   | Modifier   | Type                            | Description                                                       |
| -------------------------- | ---------- | ------------------------------- | ----------------------------------------------------------------- |
| <a id="auth" /> `auth`     | `readonly` | [`AuthClient`](#authclient)     | Low-level auth client for minting tokens directly via `/v1/auth`. |
| <a id="upload" /> `upload` | `readonly` | [`UploadClient`](#uploadclient) | Upload-mode analysis client (`POST /v1/upload/analyze`).          |

#### Methods

##### stream()

```ts theme={null}
stream(options?): StreamClient;
```

Create a new [StreamClient](#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

| Parameter | Type                              |
| --------- | --------------------------------- |
| `options` | [`StreamOptions`](#streamoptions) |

###### Returns

[`StreamClient`](#streamclient)

##### realtime()

```ts theme={null}
realtime(): RealtimeClient;
```

Create a new [RealtimeClient](#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`](#realtimeclient)

##### getToken()

```ts theme={null}
getToken(): Promise<string>;
```

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

* [`InterhumanApiError`](#interhumanapierror)
* [`InterhumanConfigError`](#interhumanconfigerror)
* [`UploadJobTimeoutError`](#uploadjobtimeouterror)

#### Constructors

##### Constructor

```ts theme={null}
new InterhumanError(message): InterhumanError;
```

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `message` | `string` |

###### Returns

[`InterhumanError`](#interhumanerror)

###### Overrides

```ts theme={null}
Error.constructor
```

***

### InterhumanApiError

An error response from an HTTP endpoint (`/v1/auth`, `/v1/upload/analyze`).

`errorId`, `correlationId`, and `link` are surfaced from the canonical
[ApiErrorBody](#apierrorbody) when the server returned one.

#### Extends

* [`InterhumanError`](#interhumanerror)

#### Constructors

##### Constructor

```ts theme={null}
new InterhumanApiError(args): InterhumanApiError;
```

###### Parameters

| Parameter       | Type                                                                                     |
| --------------- | ---------------------------------------------------------------------------------------- |
| `args`          | \{ `status`: `number`; `body?`: [`ApiErrorBody`](#apierrorbody); `message?`: `string`; } |
| `args.status`   | `number`                                                                                 |
| `args.body?`    | [`ApiErrorBody`](#apierrorbody)                                                          |
| `args.message?` | `string`                                                                                 |

###### Returns

[`InterhumanApiError`](#interhumanapierror)

###### Overrides

[`InterhumanError`](#interhumanerror).[`constructor`](#constructor-4)

#### Properties

| Property                                  | Modifier   | Type                            | Description                                               |
| ----------------------------------------- | ---------- | ------------------------------- | --------------------------------------------------------- |
| <a id="status" /> `status`                | `readonly` | `number`                        | HTTP status code.                                         |
| <a id="errorid" /> `errorId?`             | `readonly` | `string`                        | Machine-readable error code, when present.                |
| <a id="correlationid" /> `correlationId?` | `readonly` | `string`                        | Correlation id for support, when present.                 |
| <a id="link-1" /> `link?`                 | `readonly` | `string`                        | Documentation link for the error, when present.           |
| <a id="body" /> `body?`                   | `readonly` | [`ApiErrorBody`](#apierrorbody) | The raw parsed error body, when the server returned JSON. |

***

### UploadJobTimeoutError

An upload job did not reach a terminal state within the wait the caller
allowed ([UploadClient.waitForJob](#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

* [`InterhumanError`](#interhumanerror)

#### Constructors

##### Constructor

```ts theme={null}
new UploadJobTimeoutError(message, job): UploadJobTimeoutError;
```

###### Parameters

| Parameter | Type      |
| --------- | --------- |
| `message` | `string`  |
| `job`     | `unknown` |

###### Returns

[`UploadJobTimeoutError`](#uploadjobtimeouterror)

###### Overrides

[`InterhumanError`](#interhumanerror).[`constructor`](#constructor-4)

#### Properties

| Property             | Modifier   | Type      | Description                                         |
| -------------------- | ---------- | --------- | --------------------------------------------------- |
| <a id="job" /> `job` | `readonly` | `unknown` | The last job envelope read before the wait gave up. |

***

### InterhumanConfigError

A configuration/usage error caught before any network call.

Stream `error` envelopes are not thrown — they are delivered as typed
[StreamErrorEvent](#streamerrorevent)s through the stream client's `on("error", …)`
surface, and transport-level socket failures arrive on `"socketError"` as a
base [InterhumanError](#interhumanerror).

#### Extends

* [`InterhumanError`](#interhumanerror)

#### Constructors

##### Constructor

```ts theme={null}
new InterhumanConfigError(message): InterhumanConfigError;
```

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `message` | `string` |

###### Returns

[`InterhumanConfigError`](#interhumanconfigerror)

###### Inherited from

[`InterhumanError`](#interhumanerror).[`constructor`](#constructor-4)

***

### 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](#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

```ts theme={null}
const realtime = client.realtime();
realtime.on("signal.detected", (e) => console.log(e.data.signal_type));
realtime.on("realtime_recommendation.generated", (e) => console.log(e.data.text));
await realtime.connect();
await realtime.waitForSessionReady();
realtime.updateConfig({
  realtime_recommendation_instructions: "Goal: help me close a sales call.",
  realtime_recommendation_frequency: "medium",
});
realtime.sendVideo(chunk);
realtime.requestClose(); // graceful: drains (incl. recommendation), then session.ended + close
```

#### Extends

* [`SessionSocketClient`](#abstract-sessionsocketclient)\<[`RealtimeEventMap`](#realtimeeventmap), [`RealtimeSessionConfig`](#realtimesessionconfig)>

#### Constructors

##### Constructor

```ts theme={null}
new RealtimeClient(options): RealtimeClient;
```

###### Parameters

| Parameter | Type                                                        |
| --------- | ----------------------------------------------------------- |
| `options` | [`SessionSocketClientOptions`](#sessionsocketclientoptions) |

###### Returns

[`RealtimeClient`](#realtimeclient)

###### Overrides

[`SessionSocketClient`](#abstract-sessionsocketclient).[`constructor`](#constructor-9)

#### Properties

| Property                                    | Modifier   | Type                                                           | Default value                                                  | Description                                                                                                                                                                                                                | Overrides                                                                                | Inherited from                                                                               |
| ------------------------------------------- | ---------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| <a id="endpointpath" /> `endpointPath`      | `readonly` | `"/v0/realtime/analyze"`                                       | `"/v0/realtime/analyze"`                                       | Endpoint path appended to the WebSocket base URL (e.g. `/v1/stream/analyze`).                                                                                                                                              | [`SessionSocketClient`](#abstract-sessionsocketclient).[`endpointPath`](#endpointpath-1) | -                                                                                            |
| <a id="clientname" /> `clientName`          | `readonly` | `"RealtimeClient"`                                             | `"RealtimeClient"`                                             | How configuration error messages name this client. Usually the concrete class name; a client serving several endpoints may qualify it.                                                                                     | [`SessionSocketClient`](#abstract-sessionsocketclient).[`clientName`](#clientname-1)     | -                                                                                            |
| <a id="displayname" /> `displayName`        | `readonly` | `"Realtime"`                                                   | `"Realtime"`                                                   | Human-readable surface name used in error messages (e.g. `"Stream"`).                                                                                                                                                      | [`SessionSocketClient`](#abstract-sessionsocketclient).[`displayName`](#displayname-1)   | -                                                                                            |
| <a id="scopehint" /> `scopeHint`            | `readonly` | `"The credentials may be invalid or lack the realtime scope."` | `"The credentials may be invalid or lack the realtime scope."` | Appended to the connect-rejection message to hint at the likely scope issue.                                                                                                                                               | [`SessionSocketClient`](#abstract-sessionsocketclient).[`scopeHint`](#scopehint-1)       | -                                                                                            |
| <a id="framenoun" /> `frameNoun?`           | `readonly` | `string`                                                       | `undefined`                                                    | How frame-decoding messages name the surface mid-sentence (e.g. `"stream"` in "Received a malformed stream frame."). Defaults to the lowercased [displayName](#displayname); set it where that would mangle a proper noun. | -                                                                                        | [`SessionSocketClient`](#abstract-sessionsocketclient).[`frameNoun`](#framenoun-1)           |
| <a id="handshakequery" /> `handshakeQuery?` | `readonly` | `Readonly`\<`Record`\<`string`, `string`>>                     | `undefined`                                                    | Query parameters carried on the upgrade request, beside the SDK identity pair. Unset for a client whose endpoint takes none; the stream client sets it to name the model a `/v2` session opens on.                         | -                                                                                        | [`SessionSocketClient`](#abstract-sessionsocketclient).[`handshakeQuery`](#handshakequery-1) |

#### Accessors

##### isOpen

###### Get Signature

```ts theme={null}
get isOpen(): boolean;
```

Whether the underlying socket is open.

###### Returns

`boolean`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`isOpen`](#isopen-1)

#### Methods

##### sendTranscript()

```ts theme={null}
sendTranscript(transcript): void;
```

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

| Parameter    | Type                                         |
| ------------ | -------------------------------------------- |
| `transcript` | [`TranscriptSegment`](#transcriptsegment)\[] |

###### Returns

`void`

##### on()

```ts theme={null}
on<K>(event, handler): () => void;
```

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

| Type Parameter                                              |
| ----------------------------------------------------------- |
| `K` *extends* keyof [`RealtimeEventMap`](#realtimeeventmap) |

###### Parameters

| Parameter | Type                                                                    |
| --------- | ----------------------------------------------------------------------- |
| `event`   | `K`                                                                     |
| `handler` | [`Listener`](#listener)\<[`RealtimeEventMap`](#realtimeeventmap)\[`K`]> |

###### Returns

() => `void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`on`](#on-1)

##### off()

```ts theme={null}
off<K>(event, handler): void;
```

Unsubscribe a previously registered handler.

###### Type Parameters

| Type Parameter                                              |
| ----------------------------------------------------------- |
| `K` *extends* keyof [`RealtimeEventMap`](#realtimeeventmap) |

###### Parameters

| Parameter | Type                                                                    |
| --------- | ----------------------------------------------------------------------- |
| `event`   | `K`                                                                     |
| `handler` | [`Listener`](#listener)\<[`RealtimeEventMap`](#realtimeeventmap)\[`K`]> |

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`off`](#off-1)

##### once()

```ts theme={null}
once<K>(event, handler): () => void;
```

Subscribe to the next occurrence of an event, then auto-unsubscribe.

###### Type Parameters

| Type Parameter                                              |
| ----------------------------------------------------------- |
| `K` *extends* keyof [`RealtimeEventMap`](#realtimeeventmap) |

###### Parameters

| Parameter | Type                                                                    |
| --------- | ----------------------------------------------------------------------- |
| `event`   | `K`                                                                     |
| `handler` | [`Listener`](#listener)\<[`RealtimeEventMap`](#realtimeeventmap)\[`K`]> |

###### Returns

() => `void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`once`](#once-1)

##### connect()

```ts theme={null}
connect(): Promise<void>;
```

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`](#abstract-sessionsocketclient).[`connect`](#connect-1)

##### waitForSessionReady()

```ts theme={null}
waitForSessionReady(): Promise<RealtimeSessionReadyEvent>;
```

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](#connect) without racing the frame.

Rejects with an [InterhumanError](#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](#connect) and awaits `connect()` first, should attach a
`.catch()` so a refused session is not an unhandled rejection.

###### Returns

`Promise`\<[`RealtimeSessionReadyEvent`](#realtimesessionreadyevent)>

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`waitForSessionReady`](#waitforsessionready-1)

##### sendVideo()

```ts theme={null}
sendVideo(chunk): void;
```

Send a chunk of WebM or fragmented-MP4 video as a binary frame.

###### Parameters

| Parameter | Type                        |
| --------- | --------------------------- |
| `chunk`   | [`VideoChunk`](#videochunk) |

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`sendVideo`](#sendvideo-1)

##### sendBinary()

```ts theme={null}
protected sendBinary(payload): void;
```

Send an arbitrary binary frame.

###### Parameters

| Parameter | Type                                                                                                                                                                                 |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `payload` | \| `Blob` \| `ArrayBuffer` \| `Uint8Array`\<`ArrayBufferLike`> \| `ArrayBufferView`\<`ArrayBufferLike`> \| `Uint8Array`\<`ArrayBufferLike`> \| `ArrayBufferView`\<`ArrayBufferLike`> |

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`sendBinary`](#sendbinary-1)

##### updateConfig()

```ts theme={null}
updateConfig(config): void;
```

Send (or replace) the session config. Each frame fully replaces the active
config; the server acknowledges with a `session.updated` envelope.

###### Parameters

| Parameter | Type                                              |
| --------- | ------------------------------------------------- |
| `config`  | [`RealtimeSessionConfig`](#realtimesessionconfig) |

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`updateConfig`](#updateconfig-1)

##### requestClose()

```ts theme={null}
requestClose(): void;
```

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](#close).

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`requestClose`](#requestclose-1)

##### close()

```ts theme={null}
close(code?, reason?): void;
```

Close the connection immediately, without the graceful drain handshake.

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `code?`   | `number` |
| `reason?` | `string` |

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`close`](#close-3)

##### sendJson()

```ts theme={null}
protected sendJson(payload): void;
```

Send an arbitrary JSON payload as a text frame.

###### Parameters

| Parameter | Type      |
| --------- | --------- |
| `payload` | `unknown` |

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`sendJson`](#sendjson-1)

***

### `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](#on-1) surface; outbound video is sent as binary frames and JSON
payloads (session config, and for realtime the transcript) as text frames.

#### Extended by

* [`StreamClient`](#streamclient)
* [`RealtimeClient`](#realtimeclient)

#### Type Parameters

| Type Parameter                                                                                         | Description                                                                                                                                 |
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `TEventMap` *extends* [`SessionSocketEventMapBase`](#sessionsocketeventmapbase)\<`unknown`, `unknown`> | Event payloads keyed by event name (envelope `type`s plus the lifecycle events of [SessionSocketEventMapBase](#sessionsocketeventmapbase)). |
| `TConfig` *extends* `object`                                                                           | The client→server session-config shape.                                                                                                     |

#### Constructors

##### Constructor

```ts theme={null}
new SessionSocketClient<TEventMap, TConfig>(options): SessionSocketClient<TEventMap, TConfig>;
```

###### Parameters

| Parameter | Type                                                        |
| --------- | ----------------------------------------------------------- |
| `options` | [`SessionSocketClientOptions`](#sessionsocketclientoptions) |

###### Returns

[`SessionSocketClient`](#abstract-sessionsocketclient)\<`TEventMap`, `TConfig`>

#### Properties

| Property                                      | Modifier   | Type                                       | Description                                                                                                                                                                                                                  |
| --------------------------------------------- | ---------- | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="endpointpath-1" /> `endpointPath`      | `abstract` | `string`                                   | Endpoint path appended to the WebSocket base URL (e.g. `/v1/stream/analyze`).                                                                                                                                                |
| <a id="clientname-1" /> `clientName`          | `abstract` | `string`                                   | How configuration error messages name this client. Usually the concrete class name; a client serving several endpoints may qualify it.                                                                                       |
| <a id="displayname-1" /> `displayName`        | `abstract` | `string`                                   | Human-readable surface name used in error messages (e.g. `"Stream"`).                                                                                                                                                        |
| <a id="framenoun-1" /> `frameNoun?`           | `readonly` | `string`                                   | How frame-decoding messages name the surface mid-sentence (e.g. `"stream"` in "Received a malformed stream frame."). Defaults to the lowercased [displayName](#displayname-1); set it where that would mangle a proper noun. |
| <a id="scopehint-1" /> `scopeHint`            | `abstract` | `string`                                   | Appended to the connect-rejection message to hint at the likely scope issue.                                                                                                                                                 |
| <a id="handshakequery-1" /> `handshakeQuery?` | `readonly` | `Readonly`\<`Record`\<`string`, `string`>> | Query parameters carried on the upgrade request, beside the SDK identity pair. Unset for a client whose endpoint takes none; the stream client sets it to name the model a `/v2` session opens on.                           |

#### Accessors

##### isOpen

###### Get Signature

```ts theme={null}
get isOpen(): boolean;
```

Whether the underlying socket is open.

###### Returns

`boolean`

#### Methods

##### on()

```ts theme={null}
on<K>(event, handler): () => void;
```

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

| Type Parameter                                 |
| ---------------------------------------------- |
| `K` *extends* `string` \| `number` \| `symbol` |

###### Parameters

| Parameter | Type                                        |
| --------- | ------------------------------------------- |
| `event`   | `K`                                         |
| `handler` | [`Listener`](#listener)\<`TEventMap`\[`K`]> |

###### Returns

() => `void`

##### off()

```ts theme={null}
off<K>(event, handler): void;
```

Unsubscribe a previously registered handler.

###### Type Parameters

| Type Parameter                                 |
| ---------------------------------------------- |
| `K` *extends* `string` \| `number` \| `symbol` |

###### Parameters

| Parameter | Type                                        |
| --------- | ------------------------------------------- |
| `event`   | `K`                                         |
| `handler` | [`Listener`](#listener)\<`TEventMap`\[`K`]> |

###### Returns

`void`

##### once()

```ts theme={null}
once<K>(event, handler): () => void;
```

Subscribe to the next occurrence of an event, then auto-unsubscribe.

###### Type Parameters

| Type Parameter                                 |
| ---------------------------------------------- |
| `K` *extends* `string` \| `number` \| `symbol` |

###### Parameters

| Parameter | Type                                        |
| --------- | ------------------------------------------- |
| `event`   | `K`                                         |
| `handler` | [`Listener`](#listener)\<`TEventMap`\[`K`]> |

###### Returns

() => `void`

##### connect()

```ts theme={null}
connect(): Promise<void>;
```

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()

```ts theme={null}
waitForSessionReady(): Promise<TEventMap["session.ready"]>;
```

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](#connect-1) without racing the frame.

Rejects with an [InterhumanError](#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](#connect-1) and awaits `connect()` first, should attach a
`.catch()` so a refused session is not an unhandled rejection.

###### Returns

`Promise`\<`TEventMap`\[`"session.ready"`]>

##### sendVideo()

```ts theme={null}
sendVideo(chunk): void;
```

Send a chunk of WebM or fragmented-MP4 video as a binary frame.

###### Parameters

| Parameter | Type                        |
| --------- | --------------------------- |
| `chunk`   | [`VideoChunk`](#videochunk) |

###### Returns

`void`

##### sendBinary()

```ts theme={null}
protected sendBinary(payload): void;
```

Send an arbitrary binary frame.

###### Parameters

| Parameter | Type                                                                                                                                                                                 |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `payload` | \| `Blob` \| `ArrayBuffer` \| `Uint8Array`\<`ArrayBufferLike`> \| `ArrayBufferView`\<`ArrayBufferLike`> \| `Uint8Array`\<`ArrayBufferLike`> \| `ArrayBufferView`\<`ArrayBufferLike`> |

###### Returns

`void`

##### updateConfig()

```ts theme={null}
updateConfig(config): void;
```

Send (or replace) the session config. Each frame fully replaces the active
config; the server acknowledges with a `session.updated` envelope.

###### Parameters

| Parameter | Type      |
| --------- | --------- |
| `config`  | `TConfig` |

###### Returns

`void`

##### requestClose()

```ts theme={null}
requestClose(): void;
```

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](#close-3).

###### Returns

`void`

##### close()

```ts theme={null}
close(code?, reason?): void;
```

Close the connection immediately, without the graceful drain handshake.

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `code?`   | `number` |
| `reason?` | `string` |

###### Returns

`void`

##### sendJson()

```ts theme={null}
protected sendJson(payload): void;
```

Send an arbitrary JSON payload as a text frame.

###### Parameters

| Parameter | Type      |
| --------- | --------- |
| `payload` | `unknown` |

###### 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](#abstract-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](#apiversion-1). 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](#model-1) (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](#sendaudio) instead of container media.

#### Examples

```ts theme={null}
const stream = client.stream();               // Inter-1, /v1/stream/analyze
const streamV2 = client.stream({ apiVersion: "v2" }); // Inter-2, /v2/stream/analyze
stream.on("signal.detected", (e) => console.log(e.data.signal_type));
await stream.connect();
await stream.waitForSessionReady();
stream.updateConfig({ include: ["conversation_quality_overall"] });
stream.sendVideo(chunk);
stream.requestClose(); // graceful: drains, then session.ended + close
```

```ts theme={null}
// Needs the interhumanai.stream.inter-2-audio scope.
const audio = client.stream({ apiVersion: "v2", model: "inter-2-audio" });
await audio.connect();
await audio.waitForSessionReady();
audio.updateConfig({
  audio_format: { encoding: "pcm_s16le", sample_rate: 16000, channels: 1 },
});
audio.sendAudio(pcmFrame); // signed 16-bit mono PCM, any frame size
```

#### Extends

* [`SessionSocketClient`](#abstract-sessionsocketclient)\<[`StreamEventMap`](#streameventmap), [`StreamSessionConfig`](#streamsessionconfig)>

#### Constructors

##### Constructor

```ts theme={null}
new StreamClient(options): StreamClient;
```

###### Parameters

| Parameter | Type                                          |
| --------- | --------------------------------------------- |
| `options` | [`StreamClientOptions`](#streamclientoptions) |

###### Returns

[`StreamClient`](#streamclient)

###### Overrides

[`SessionSocketClient`](#abstract-sessionsocketclient).[`constructor`](#constructor-9)

#### Properties

| Property                                      | Modifier   | Type                                           | Description                                                                                                                                                                                                                  | Overrides                                                                                    |
| --------------------------------------------- | ---------- | ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| <a id="endpointpath-2" /> `endpointPath`      | `readonly` | `string`                                       | Endpoint path appended to the WebSocket base URL (e.g. `/v1/stream/analyze`).                                                                                                                                                | [`SessionSocketClient`](#abstract-sessionsocketclient).[`endpointPath`](#endpointpath-1)     |
| <a id="clientname-2" /> `clientName`          | `readonly` | `string`                                       | How configuration error messages name this client. Usually the concrete class name; a client serving several endpoints may qualify it.                                                                                       | [`SessionSocketClient`](#abstract-sessionsocketclient).[`clientName`](#clientname-1)         |
| <a id="displayname-2" /> `displayName`        | `readonly` | `string`                                       | Human-readable surface name used in error messages (e.g. `"Stream"`).                                                                                                                                                        | [`SessionSocketClient`](#abstract-sessionsocketclient).[`displayName`](#displayname-1)       |
| <a id="framenoun-2" /> `frameNoun`            | `readonly` | `string`                                       | How frame-decoding messages name the surface mid-sentence (e.g. `"stream"` in "Received a malformed stream frame."). Defaults to the lowercased [displayName](#displayname-2); set it where that would mangle a proper noun. | [`SessionSocketClient`](#abstract-sessionsocketclient).[`frameNoun`](#framenoun-1)           |
| <a id="scopehint-2" /> `scopeHint`            | `readonly` | `string`                                       | Appended to the connect-rejection message to hint at the likely scope issue.                                                                                                                                                 | [`SessionSocketClient`](#abstract-sessionsocketclient).[`scopeHint`](#scopehint-1)           |
| <a id="handshakequery-2" /> `handshakeQuery?` | `readonly` | `Readonly`\<`Record`\<`string`, `string`>>     | Query parameters carried on the upgrade request, beside the SDK identity pair. Unset for a client whose endpoint takes none; the stream client sets it to name the model a `/v2` session opens on.                           | [`SessionSocketClient`](#abstract-sessionsocketclient).[`handshakeQuery`](#handshakequery-1) |
| <a id="apiversion-2" /> `apiVersion`          | `readonly` | [`StreamApiVersion`](#streamapiversion)        | The stream endpoint this client opens.                                                                                                                                                                                       | -                                                                                            |
| <a id="model-2" /> `model`                    | `readonly` | [`StreamModel`](#streammodel-1) \| `undefined` | The model a `"v2"` session opens on, as named at construction; `undefined` on `"v1"` and when the server default (`"inter-2"`) is left to apply.                                                                             | -                                                                                            |

#### Accessors

##### isOpen

###### Get Signature

```ts theme={null}
get isOpen(): boolean;
```

Whether the underlying socket is open.

###### Returns

`boolean`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`isOpen`](#isopen-1)

#### Methods

##### on()

```ts theme={null}
on<K>(event, handler): () => void;
```

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

| Type Parameter                                          |
| ------------------------------------------------------- |
| `K` *extends* keyof [`StreamEventMap`](#streameventmap) |

###### Parameters

| Parameter | Type                                                                |
| --------- | ------------------------------------------------------------------- |
| `event`   | `K`                                                                 |
| `handler` | [`Listener`](#listener)\<[`StreamEventMap`](#streameventmap)\[`K`]> |

###### Returns

() => `void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`on`](#on-1)

##### off()

```ts theme={null}
off<K>(event, handler): void;
```

Unsubscribe a previously registered handler.

###### Type Parameters

| Type Parameter                                          |
| ------------------------------------------------------- |
| `K` *extends* keyof [`StreamEventMap`](#streameventmap) |

###### Parameters

| Parameter | Type                                                                |
| --------- | ------------------------------------------------------------------- |
| `event`   | `K`                                                                 |
| `handler` | [`Listener`](#listener)\<[`StreamEventMap`](#streameventmap)\[`K`]> |

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`off`](#off-1)

##### once()

```ts theme={null}
once<K>(event, handler): () => void;
```

Subscribe to the next occurrence of an event, then auto-unsubscribe.

###### Type Parameters

| Type Parameter                                          |
| ------------------------------------------------------- |
| `K` *extends* keyof [`StreamEventMap`](#streameventmap) |

###### Parameters

| Parameter | Type                                                                |
| --------- | ------------------------------------------------------------------- |
| `event`   | `K`                                                                 |
| `handler` | [`Listener`](#listener)\<[`StreamEventMap`](#streameventmap)\[`K`]> |

###### Returns

() => `void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`once`](#once-1)

##### connect()

```ts theme={null}
connect(): Promise<void>;
```

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`](#abstract-sessionsocketclient).[`connect`](#connect-1)

##### waitForSessionReady()

```ts theme={null}
waitForSessionReady(): Promise<SessionReadyEvent>;
```

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](#connect-2) without racing the frame.

Rejects with an [InterhumanError](#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](#connect-2) and awaits `connect()` first, should attach a
`.catch()` so a refused session is not an unhandled rejection.

###### Returns

`Promise`\<[`SessionReadyEvent`](#sessionreadyevent)>

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`waitForSessionReady`](#waitforsessionready-1)

##### sendVideo()

```ts theme={null}
sendVideo(chunk): void;
```

Send a chunk of WebM or fragmented-MP4 video as a binary frame.

###### Parameters

| Parameter | Type                        |
| --------- | --------------------------- |
| `chunk`   | [`VideoChunk`](#videochunk) |

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`sendVideo`](#sendvideo-1)

##### sendBinary()

```ts theme={null}
protected sendBinary(payload): void;
```

Send an arbitrary binary frame.

###### Parameters

| Parameter | Type                                                                                                                                                                                 |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `payload` | \| `Blob` \| `ArrayBuffer` \| `Uint8Array`\<`ArrayBufferLike`> \| `ArrayBufferView`\<`ArrayBufferLike`> \| `Uint8Array`\<`ArrayBufferLike`> \| `ArrayBufferView`\<`ArrayBufferLike`> |

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`sendBinary`](#sendbinary-1)

##### updateConfig()

```ts theme={null}
updateConfig(config): void;
```

Send (or replace) the session config. Each frame fully replaces the active
config; the server acknowledges with a `session.updated` envelope.

###### Parameters

| Parameter | Type                                          |
| --------- | --------------------------------------------- |
| `config`  | [`StreamSessionConfig`](#streamsessionconfig) |

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`updateConfig`](#updateconfig-1)

##### requestClose()

```ts theme={null}
requestClose(): void;
```

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](#close-4).

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`requestClose`](#requestclose-1)

##### close()

```ts theme={null}
close(code?, reason?): void;
```

Close the connection immediately, without the graceful drain handshake.

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `code?`   | `number` |
| `reason?` | `string` |

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`close`](#close-3)

##### sendJson()

```ts theme={null}
protected sendJson(payload): void;
```

Send an arbitrary JSON payload as a text frame.

###### Parameters

| Parameter | Type      |
| --------- | --------- |
| `payload` | `unknown` |

###### Returns

`void`

###### Inherited from

[`SessionSocketClient`](#abstract-sessionsocketclient).[`sendJson`](#sendjson-1)

##### sendAudio()

```ts theme={null}
sendAudio(frame): void;
```

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](#sendvideo-2) names.

###### Parameters

| Parameter | Type                        |
| --------- | --------------------------- |
| `frame`   | [`AudioFrame`](#audioframe) |

###### Returns

`void`

***

### UploadClient

Analyzes complete files.

[analyze](#analyze) is the v1 route: the file is analyzed inside the request and
the report comes back with the response. [submit](#submit), [getJob](#getjob) and
[waitForJob](#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](#tokenprovider).

#### Constructors

##### Constructor

```ts theme={null}
new UploadClient(options): UploadClient;
```

###### Parameters

| Parameter | Type                                          |
| --------- | --------------------------------------------- |
| `options` | [`UploadClientOptions`](#uploadclientoptions) |

###### Returns

[`UploadClient`](#uploadclient)

#### Methods

##### analyze()

```ts theme={null}
analyze(input): Promise<AnalysisResult>;
```

Analyze a video file in upload mode.

###### Parameters

| Parameter | Type                                        |
| --------- | ------------------------------------------- |
| `input`   | [`AnalyzeUploadInput`](#analyzeuploadinput) |

###### Returns

`Promise`\<[`AnalysisResult`](#analysisresult)>

###### Throws

on a rejected request (auth, validation,
too-large/too-short media, quota, unprocessable video, server error).

##### submit()

```ts theme={null}
submit(input): Promise<UploadJob>;
```

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](#waitforjob) or [getJob](#getjob) reads it
later. Check `status` rather than assuming either.

###### Parameters

| Parameter | Type                                            |
| --------- | ----------------------------------------------- |
| `input`   | [`SubmitUploadJobInput`](#submituploadjobinput) |

###### Returns

`Promise`\<[`UploadJob`](#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()

```ts theme={null}
getJob(job, options?): Promise<UploadJob>;
```

Read a job's current envelope from `GET /v2/upload/jobs/{job_id}`.

###### Parameters

| Parameter         | Type                                  | Description                                               |
| ----------------- | ------------------------------------- | --------------------------------------------------------- |
| `job`             | `string` \| [`UploadJob`](#uploadjob) | The job's id, or the envelope [submit](#submit) returned. |
| `options`         | \{ `signal?`: `AbortSignal`; }        | -                                                         |
| `options.signal?` | `AbortSignal`                         | -                                                         |

###### Returns

`Promise`\<[`UploadJob`](#uploadjob)>

###### Throws

`ih4021` (404) when the id is unknown to this
account or the job has expired, among the usual errors.

##### waitForJob()

```ts theme={null}
waitForJob(job, options?): Promise<UploadJob>;
```

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

| Parameter | Type                                      |
| --------- | ----------------------------------------- |
| `job`     | `string` \| [`UploadJob`](#uploadjob)     |
| `options` | [`WaitForJobOptions`](#waitforjoboptions) |

###### Returns

`Promise`\<[`UploadJob`](#uploadjob)>

###### Throws

when `timeoutMs` elapses first. The job
keeps running; the error carries the last envelope read.

## Interfaces

### AuthClientOptions

Options for constructing an [AuthClient](#authclient).

#### Properties

| Property                              | Type                                                                                         | Description                                                                |
| ------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| <a id="baseurl" /> `baseUrl?`         | `string`                                                                                     | Explicit base URL (e.g. `http://localhost:8080`). Overrides `environment`. |
| <a id="environment" /> `environment?` | [`Environment`](#environment-2)                                                              | Named environment to target. Defaults to `"production"`.                   |
| <a id="fetch" /> `fetch?`             | \{ (`input`, `init?`): `Promise`\<`Response`>; (`input`, `init?`): `Promise`\<`Response`>; } | Custom `fetch` implementation. Defaults to the global `fetch`.             |

***

### TokenProvider

Anything that can supply a bearer token on demand.

#### Methods

##### getToken()

```ts theme={null}
getToken(): Promise<string>;
```

Return a currently-valid bearer token, minting/refreshing as needed.

###### Returns

`Promise`\<`string`>

***

### TokenManagerOptions

Options for a [TokenManager](#tokenmanager).

#### Properties

| Property                                            | Type                                      | Description                                                                                                                    |
| --------------------------------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| <a id="authclient-1" /> `authClient`                | [`AuthClient`](#authclient)               | -                                                                                                                              |
| <a id="credentials" /> `credentials`                | [`ApiKeyCredentials`](#apikeycredentials) | -                                                                                                                              |
| <a id="scopes" /> `scopes`                          | [`ScopeValue`](#scopevalue)\[]            | Scopes to request when minting tokens.                                                                                         |
| <a id="refreshskewseconds" /> `refreshSkewSeconds?` | `number`                                  | Refresh a cached token this many seconds *before* its stated expiry, to absorb clock skew and request latency. Defaults to 30. |
| <a id="now" /> `now?`                               | () => `number`                            | Injectable clock (milliseconds). Defaults to `Date.now`. Test seam.                                                            |

***

### ApiKeyCredentials

Credentials issued in the Interhuman customer platform.

#### Extended by

* [`TokenRequest`](#tokenrequest)

#### Properties

| Property                         | Type     | Description                        |
| -------------------------------- | -------- | ---------------------------------- |
| <a id="keyid" /> `keyId`         | `string` | API key ID from the dashboard.     |
| <a id="keysecret" /> `keySecret` | `string` | API key secret from the dashboard. |

***

### ApiKeyCredential

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

#### Extended by

* [`ClientTokenRequest`](#clienttokenrequest)
* [`RevokeClientTokenRequest`](#revokeclienttokenrequest)

#### Properties

| Property                   | Type     | Description                                                             |
| -------------------------- | -------- | ----------------------------------------------------------------------- |
| <a id="apikey" /> `apiKey` | `string` | Your full API key from the dashboard (`ih_<env>_<publicId>_<entropy>`). |

***

### TokenRequest

Request body for `POST /v1/auth`.

#### Extends

* [`ApiKeyCredentials`](#apikeycredentials)

#### Properties

| Property                           | Type                           | Description                                 | Inherited from                                                      |
| ---------------------------------- | ------------------------------ | ------------------------------------------- | ------------------------------------------------------------------- |
| <a id="keyid-1" /> `keyId`         | `string`                       | API key ID from the dashboard.              | [`ApiKeyCredentials`](#apikeycredentials).[`keyId`](#keyid)         |
| <a id="keysecret-1" /> `keySecret` | `string`                       | API key secret from the dashboard.          | [`ApiKeyCredentials`](#apikeycredentials).[`keySecret`](#keysecret) |
| <a id="scopes-1" /> `scopes`       | [`ScopeValue`](#scopevalue)\[] | Requested scopes; at least one is required. | -                                                                   |

***

### TokenResponse

Response body from `POST /v1/auth`.

#### Properties

| Property                               | Type     | Description                                      |
| -------------------------------------- | -------- | ------------------------------------------------ |
| <a id="access_token" /> `access_token` | `string` | The minted bearer access token (a JWT).          |
| <a id="token_type" /> `token_type`     | `string` | Token type; always `"Bearer"`.                   |
| <a id="expires_in" /> `expires_in`     | `number` | Seconds until the token expires (typically 900). |
| <a id="scope" /> `scope`               | `string` | Space-separated list of granted scopes.          |

***

### 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](#scopes-2)
(default `interhumanai.stream`); the caps are enforced on streaming sessions
(stream / realtime) and the video budget additionally spans upload.

#### Extends

* [`ApiKeyCredential`](#apikeycredential)

#### Properties

| Property                                            | Type                           | Description                                                                                                               | Inherited from                                              |
| --------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| <a id="apikey-1" /> `apiKey`                        | `string`                       | Your full API key from the dashboard (`ih_<env>_<publicId>_<entropy>`).                                                   | [`ApiKeyCredential`](#apikeycredential).[`apiKey`](#apikey) |
| <a id="scopes-2" /> `scopes?`                       | [`ScopeValue`](#scopevalue)\[] | Scopes to grant the token. Defaults to `["interhumanai.stream"]`.                                                         | -                                                           |
| <a id="expiresin" /> `expiresIn?`                   | `number`                       | Requested lifetime in seconds. Clamped to 60–3600; defaults to 300.                                                       | -                                                           |
| <a id="maxdurationseconds" /> `maxDurationSeconds?` | `number`                       | Max wall-clock duration, in seconds, of a session opened with this token.                                                 | -                                                           |
| <a id="maxbytes" /> `maxBytes?`                     | `number`                       | Max cumulative video bytes a session opened with this token may send.                                                     | -                                                           |
| <a id="maxconcurrent" /> `maxConcurrent?`           | `number`                       | Max number of concurrent sessions opened with this token. Defaults to 1 (one session at a time) when omitted server-side. | -                                                           |
| <a id="maxvideoseconds" /> `maxVideoSeconds?`       | `number`                       | Max total seconds of video the token may process across upload/stream/realtime.                                           | -                                                           |
| <a id="allowedorigins" /> `allowedOrigins?`         | `string`\[]                    | Allow-list of browser `Origin` values permitted to use this token.                                                        | -                                                           |

***

### ClientTokenResponse

Response body from `POST /v1/client_tokens`.

#### Properties

| Property                                                | Type                  | Description                                                            |
| ------------------------------------------------------- | --------------------- | ---------------------------------------------------------------------- |
| <a id="access_token-1" /> `access_token`                | `string`              | The minted client token (a JWT).                                       |
| <a id="token_type-1" /> `token_type`                    | `string`              | Token type; always `"Bearer"`.                                         |
| <a id="expires_in-1" /> `expires_in`                    | `number`              | Seconds until the token expires.                                       |
| <a id="scope-1" /> `scope`                              | `string`              | Space-separated list of granted scopes.                                |
| <a id="max_duration_seconds" /> `max_duration_seconds?` | `number` \| `null`    | Per-token max session duration that will be enforced, if any.          |
| <a id="max_bytes" /> `max_bytes?`                       | `number` \| `null`    | Per-token max cumulative session bytes that will be enforced, if any.  |
| <a id="max_concurrent" /> `max_concurrent?`             | `number` \| `null`    | Per-token max concurrent sessions that will be enforced, if any.       |
| <a id="max_video_seconds" /> `max_video_seconds?`       | `number` \| `null`    | Per-token total video-seconds budget that will be enforced, if any.    |
| <a id="allowed_origins" /> `allowed_origins?`           | `string`\[] \| `null` | Per-token allow-list of browser origins that will be enforced, if any. |

***

### RevokeClientTokenRequest

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

#### Extends

* [`ApiKeyCredential`](#apikeycredential)

#### Properties

| Property                     | Type     | Description                                                             | Inherited from                                              |
| ---------------------------- | -------- | ----------------------------------------------------------------------- | ----------------------------------------------------------- |
| <a id="apikey-2" /> `apiKey` | `string` | Your full API key from the dashboard (`ih_<env>_<publicId>_<entropy>`). | [`ApiKeyCredential`](#apikeycredential).[`apiKey`](#apikey) |
| <a id="token" /> `token`     | `string` | The client token to revoke (as returned in `access_token`).             | -                                                           |

***

### InterhumanClientOptions

Options for constructing an [InterhumanClient](#interhumanclient).

#### Properties

| Property                                              | Type                                                                                         | Description                                                                                                                                                   |
| ----------------------------------------------------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="credentials-1" /> `credentials?`               | [`ApiKeyCredentials`](#apikeycredentials)                                                    | API-key credentials. The client exchanges these at `/v1/auth` and refreshes the resulting token automatically. Provide either `credentials` or `accessToken`. |
| <a id="accesstoken" /> `accessToken?`                 | `string`                                                                                     | A pre-issued bearer access token, used as-is. Provide either `accessToken` or `credentials`.                                                                  |
| <a id="scopes-3" /> `scopes?`                         | [`ScopeValue`](#scopevalue)\[]                                                               | Scopes requested when minting tokens from `credentials`. Defaults to upload + stream. Ignored when `accessToken` is supplied.                                 |
| <a id="environment-1" /> `environment?`               | [`Environment`](#environment-2)                                                              | Named environment to target. Defaults to `"production"`.                                                                                                      |
| <a id="baseurl-1" /> `baseUrl?`                       | `string`                                                                                     | Explicit base URL (e.g. `http://localhost:8080`). Overrides `environment`.                                                                                    |
| <a id="fetch-1" /> `fetch?`                           | \{ (`input`, `init?`): `Promise`\<`Response`>; (`input`, `init?`): `Promise`\<`Response`>; } | Custom `fetch` implementation. Defaults to the global `fetch`.                                                                                                |
| <a id="websocket" /> `webSocket?`                     | [`WebSocketFactory`](#websocketfactory)                                                      | Custom WebSocket factory for the stream and realtime clients. Defaults to the global `WebSocket` (browsers, Node 22+).                                        |
| <a id="refreshskewseconds-1" /> `refreshSkewSeconds?` | `number`                                                                                     | Seconds before stated expiry to refresh a minted token. Defaults to 30.                                                                                       |

***

### StreamOptions

Per-session options for [InterhumanClient.stream](#stream).

#### Properties

| Property                            | Type                                    | Description                                                                                                                                                                                                                                                      |
| ----------------------------------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="apiversion" /> `apiVersion?` | [`StreamApiVersion`](#streamapiversion) | Which stream endpoint to open: `"v1"` (Inter-1, the default) or `"v2"` (Inter-2). Both endpoints speak the same protocol; only the model behind the analysis differs, and with it the scope: `interhumanai.stream` for v1, `interhumanai.stream.<model>` for v2. |
| <a id="model" /> `model?`           | [`StreamModel`](#streammodel-1)         | The Inter-2 model a `"v2"` session opens on (default `"inter-2"`); the credential must carry `interhumanai.stream.<model>` for it. See [StreamClientOptions.model](#model-1).                                                                                    |

***

### ApiErrorBody

The canonical error body returned by every HTTP error path.

#### Properties

| Property                                    | Type               | Description                                                          |
| ------------------------------------------- | ------------------ | -------------------------------------------------------------------- |
| <a id="error_id" /> `error_id`              | `string`           | Machine-readable error code.                                         |
| <a id="correlation_id" /> `correlation_id?` | `string` \| `null` | Connection/request correlation id; quote it when contacting support. |
| <a id="link" /> `link?`                     | `string` \| `null` | URL with more information about this error, when available.          |
| <a id="message" /> `message?`               | `string` \| `null` | Human-readable explanation, when available.                          |

***

### TranscriptSegment

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

#### Properties

| Property                     | Type     | Description                                               |
| ---------------------------- | -------- | --------------------------------------------------------- |
| <a id="start" /> `start`     | `number` | Start time of the utterance, in seconds.                  |
| <a id="end" /> `end`         | `number` | End time of the utterance, in seconds.                    |
| <a id="text" /> `text`       | `string` | The spoken text of this segment.                          |
| <a id="speaker" /> `speaker` | `number` | Zero-based index identifying the speaker of this segment. |

***

### 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

| Property                                                                                | Type                                                                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| --------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <a id="analysis_groups" /> `analysis_groups?`                                           | [`AnalysisGroup`](#analysisgroup-1)\[]                                  | Analysis surfaces to run for this session, any subset of what the server advertises on `session.ready` under `supported_session_config_options.analysis_groups`. Must be non-empty when present: an empty array — like selecting a group the server has not enabled — is rejected with an `error` envelope. When omitted, the server default is `audio` + `visual`. The `visual` group reads the picture, so select `["audio"]` alone to analyze a stream whose recording carries no video track. Leaving `visual` selected and sending such a stream is a configuration error rather than a partial success: the server sends one `ih5001` `error` envelope and stops analyzing the session, the audio tracks included. Sending a config that narrows to `["audio"]` resumes analysis from the next window. |
| <a id="realtime_recommendation_frequency" /> `realtime_recommendation_frequency?`       | [`RealtimeRecommendationFrequency`](#realtimerecommendationfrequency-1) | How often recommendation runs once enabled. Has no effect until a non-empty `realtime_recommendation_instructions` enables recommendations.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| <a id="realtime_recommendation_instructions" /> `realtime_recommendation_instructions?` | `string` \| `null`                                                      | Configuration block for the periodic recommendation step, and the switch that enables it: the recommendation step runs only when this is a non-empty string (there is no default prompt). It sets the goal, domain/context, and the focus, tone, or output style of the guidance. It is treated as untrusted configuration data — it shapes the guidance but cannot override the recommendation task or output contract set by the active system prompt.                                                                                                                                                                                                                                                                                                                                                     |

***

### 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

| Property                           | Type                                         | Description                                                                     |
| ---------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------- |
| <a id="type" /> `type`             | `"transcript.updated"`                       | -                                                                               |
| <a id="transcript" /> `transcript` | [`TranscriptSegment`](#transcriptsegment)\[] | The full transcript as `{start, end, text, speaker}` segments, in spoken order. |

***

### 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

| Property                                                                                 | Type                                                                       | Description                                                                                                                                                      |
| ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="realtime_recommendation_instructions-1" /> `realtime_recommendation_instructions` | `"string"`                                                                 | Always the literal `"string"`: `realtime_recommendation_instructions` takes free-form text, so its accepted JSON type is advertised instead of a value list.     |
| <a id="realtime_recommendation_frequency-1" /> `realtime_recommendation_frequency`       | [`RealtimeRecommendationFrequency`](#realtimerecommendationfrequency-1)\[] | Accepted `realtime_recommendation_frequency` values.                                                                                                             |
| <a id="analysis_groups-1" /> `analysis_groups`                                           | [`AnalysisGroup`](#analysisgroup-1)\[]                                     | Analysis groups this deployment allows — the valid values for the config's `analysis_groups` field, so you can pick a subset without round-tripping a rejection. |

***

### RealtimeSessionReadyData

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

#### Properties

| Property                                                                       | Type                                                                      | Description                                                                       |
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| <a id="session_idle_timeout_seconds" /> `session_idle_timeout_seconds`         | `number`                                                                  | Idle seconds tolerated before the server closes the session (`0` = disabled).     |
| <a id="session_max_duration_seconds" /> `session_max_duration_seconds`         | `number`                                                                  | Maximum total session duration in seconds (`0` = disabled).                       |
| <a id="max_segment_duration_seconds" /> `max_segment_duration_seconds`         | `number` \| `null`                                                        | Max probed duration of one inbound chunk, or `null` when only the size cap binds. |
| <a id="min_segment_size_bytes" /> `min_segment_size_bytes`                     | `number`                                                                  | Minimum size in bytes of one inbound chunk.                                       |
| <a id="max_segment_size_bytes" /> `max_segment_size_bytes`                     | `number`                                                                  | Maximum size in bytes of one inbound chunk.                                       |
| <a id="supported_session_config_options" /> `supported_session_config_options` | [`RealtimeSessionReadyConfigOptions`](#realtimesessionreadyconfigoptions) | -                                                                                 |

***

### RealtimeSessionReadyEvent

Fields shared by every server→client envelope.

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                     | Type                                                    | Description                                                  | Inherited from                                                                    |
| -------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="type-1" /> `type`                     | `"session.ready"`                                       | -                                                            | -                                                                                 |
| <a id="data" /> `data`                       | [`RealtimeSessionReadyData`](#realtimesessionreadydata) | -                                                            | -                                                                                 |
| <a id="timestamp" /> `timestamp`             | `string`                                                | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-1" /> `correlation_id` | `string`                                                | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |

***

### 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

| Property                                                                                 | Type                                                                                 | Description                                                                                        |
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- |
| <a id="realtime_recommendation_instructions-2" /> `realtime_recommendation_instructions` | `string` \| `null`                                                                   | The applied `realtime_recommendation_instructions`, echoed back verbatim; `null` when unset.       |
| <a id="realtime_recommendation_frequency-2" /> `realtime_recommendation_frequency`       | \| [`RealtimeRecommendationFrequency`](#realtimerecommendationfrequency-1) \| `null` | The active recommendation frequency; `null` when unset.                                            |
| <a id="analysis_groups-2" /> `analysis_groups`                                           | [`AnalysisGroup`](#analysisgroup-1)\[]                                               | The effective analysis-group selection in force (the server default when you have not chosen one). |

***

### RealtimeSessionUpdatedEvent

Fields shared by every server→client envelope.

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                     | Type                                                        | Description                                                  | Inherited from                                                                    |
| -------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="type-2" /> `type`                     | `"session.updated"`                                         | -                                                            | -                                                                                 |
| <a id="data-1" /> `data`                     | [`RealtimeSessionUpdatedData`](#realtimesessionupdateddata) | -                                                            | -                                                                                 |
| <a id="timestamp-1" /> `timestamp`           | `string`                                                    | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-2" /> `correlation_id` | `string`                                                    | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |

***

### RealtimeRecommendationGeneratedData

`realtime_recommendation.generated` payload — one recommendation run's guidance text.

#### Properties

| Property                   | Type     | Description                                                                                                                                                                        |
| -------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="text-1" /> `text`   | `string` | The guidance text returned by the recommendation model — one short recommendation for the responding speaker, or the literal `NO_GUIDANCE` when the signals warrant no adjustment. |
| <a id="start-1" /> `start` | `number` | Start of the analyzed interval this recommendation covers (seconds, session time).                                                                                                 |
| <a id="end-1" /> `end`     | `number` | End of the analyzed interval this recommendation covers (seconds, session time).                                                                                                   |

***

### RealtimeRecommendationGeneratedEvent

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

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                     | Type                                                                          | Description                                                  | Inherited from                                                                    |
| -------------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="type-3" /> `type`                     | `"realtime_recommendation.generated"`                                         | -                                                            | -                                                                                 |
| <a id="data-2" /> `data`                     | [`RealtimeRecommendationGeneratedData`](#realtimerecommendationgenerateddata) | -                                                            | -                                                                                 |
| <a id="timestamp-2" /> `timestamp`           | `string`                                                                      | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-3" /> `correlation_id` | `string`                                                                      | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |

***

### RealtimeSignalDetectedData

#### Properties

| Property                             | Type                                      | Description                                                                                                                                                                 |
| ------------------------------------ | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="signal_type" /> `signal_type` | [`SignalType`](#signaltype)               | -                                                                                                                                                                           |
| <a id="start-2" /> `start`           | `number`                                  | Seconds, absolute session-cumulative time.                                                                                                                                  |
| <a id="probability" /> `probability` | [`Probability`](#probability-4) \| `null` | -                                                                                                                                                                           |
| <a id="modality" /> `modality`       | `string`\[]                               | Analysis modalities that detected this signal, naming the source of the evidence: one or both of `audio` and `visual`. When both detect the same signal, both are included. |

***

### RealtimeSignalDetectedEvent

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

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                     | Type                                                        | Description                                                  | Inherited from                                                                    |
| -------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="type-4" /> `type`                     | `"signal.detected"`                                         | -                                                            | -                                                                                 |
| <a id="data-3" /> `data`                     | [`RealtimeSignalDetectedData`](#realtimesignaldetecteddata) | -                                                            | -                                                                                 |
| <a id="timestamp-3" /> `timestamp`           | `string`                                                    | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-4" /> `correlation_id` | `string`                                                    | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |

***

### RealtimeSignalUpdatedData

#### Properties

| Property                               | Type                                      | Description                                                                                                          |
| -------------------------------------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| <a id="signal_type-1" /> `signal_type` | [`SignalType`](#signaltype)               | -                                                                                                                    |
| <a id="start-3" /> `start`             | `number`                                  | Seconds, absolute session-cumulative time.                                                                           |
| <a id="probability-1" /> `probability` | [`Probability`](#probability-4) \| `null` | -                                                                                                                    |
| <a id="modality-1" /> `modality`       | `string`\[]                               | Analyses whose evidence produced this signal. A change to this set is one of the things that emits `signal.updated`. |

***

### RealtimeSignalUpdatedEvent

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

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                     | Type                                                      | Description                                                  | Inherited from                                                                    |
| -------------------------------------------- | --------------------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="type-5" /> `type`                     | `"signal.updated"`                                        | -                                                            | -                                                                                 |
| <a id="data-4" /> `data`                     | [`RealtimeSignalUpdatedData`](#realtimesignalupdateddata) | -                                                            | -                                                                                 |
| <a id="timestamp-4" /> `timestamp`           | `string`                                                  | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-5" /> `correlation_id` | `string`                                                  | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |

***

### RealtimeEventMap

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

#### Properties

| Property                                                                        | Type                                                                            | Description                                                        |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| <a id="sessionready" /> `session.ready`                                         | [`RealtimeSessionReadyEvent`](#realtimesessionreadyevent)                       | -                                                                  |
| <a id="sessionupdated" /> `session.updated`                                     | [`RealtimeSessionUpdatedEvent`](#realtimesessionupdatedevent)                   | -                                                                  |
| <a id="sessionclosing" /> `session.closing`                                     | [`SessionClosingEvent`](#sessionclosingevent)                                   | -                                                                  |
| <a id="sessionended" /> `session.ended`                                         | [`SessionEndedEvent`](#sessionendedevent)                                       | -                                                                  |
| <a id="signaldetected" /> `signal.detected`                                     | [`RealtimeSignalDetectedEvent`](#realtimesignaldetectedevent)                   | -                                                                  |
| <a id="signalupdated" /> `signal.updated`                                       | [`RealtimeSignalUpdatedEvent`](#realtimesignalupdatedevent)                     | -                                                                  |
| <a id="signalended" /> `signal.ended`                                           | [`SignalEndedEvent`](#signalendedevent)                                         | -                                                                  |
| <a id="realtime_recommendationgenerated" /> `realtime_recommendation.generated` | [`RealtimeRecommendationGeneratedEvent`](#realtimerecommendationgeneratedevent) | -                                                                  |
| <a id="coveragedropped" /> `coverage.dropped`                                   | [`CoverageDroppedEvent`](#coveragedroppedevent)                                 | -                                                                  |
| <a id="coveragedegraded" /> `coverage.degraded`                                 | [`CoverageDegradedEvent`](#coveragedegradedevent)                               | -                                                                  |
| <a id="error" /> `error`                                                        | [`StreamErrorEvent`](#streamerrorevent)                                         | -                                                                  |
| <a id="message-1" /> `message`                                                  | [`RealtimeEvent`](#realtimeevent)                                               | Fires for every server→client envelope, regardless of type.        |
| <a id="open" /> `open`                                                          | `void`                                                                          | Fires once when the WebSocket connection opens.                    |
| <a id="close-1" /> `close`                                                      | [`StreamCloseInfo`](#streamcloseinfo)                                           | Fires once when the connection closes.                             |
| <a id="socketerror" /> `socketError`                                            | `Error`                                                                         | Transport-level socket error (distinct from the `error` envelope). |

***

### SessionSocketClientOptions

Options shared by every WebSocket session client.

#### Extended by

* [`StreamClientOptions`](#streamclientoptions)

#### Properties

| Property                                   | Type                                    | Description                                                                                                                             |
| ------------------------------------------ | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="tokenprovider-1" /> `tokenProvider` | [`TokenProvider`](#tokenprovider)       | Supplies the bearer token used to authenticate the connection.                                                                          |
| <a id="baseurl-2" /> `baseUrl?`            | `string`                                | Explicit base URL (e.g. `http://localhost:8080`). Overrides `environment`.                                                              |
| <a id="environment-3" /> `environment?`    | [`Environment`](#environment-2)         | Named environment to target. Defaults to `"production"`.                                                                                |
| <a id="websocket-1" /> `webSocket?`        | [`WebSocketFactory`](#websocketfactory) | Custom WebSocket factory. Defaults to the global `WebSocket` (browsers, Node 22+). Supply one backed by the `ws` package on older Node. |

***

### 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

| Type Parameter |
| -------------- |
| `TEvent`       |
| `TReady`       |

#### Properties

| Property                                  | Type                                  | Description                                                        |
| ----------------------------------------- | ------------------------------------- | ------------------------------------------------------------------ |
| <a id="sessionready-1" /> `session.ready` | `TReady`                              | The `session.ready` envelope — first frame after the handshake.    |
| <a id="message-2" /> `message`            | `TEvent`                              | Fires for every server→client envelope, regardless of type.        |
| <a id="open-1" /> `open`                  | `void`                                | Fires once when the WebSocket connection opens.                    |
| <a id="close-2" /> `close`                | [`StreamCloseInfo`](#streamcloseinfo) | Fires once when the connection closes.                             |
| <a id="socketerror-1" /> `socketError`    | `Error`                               | Transport-level socket error (distinct from the `error` envelope). |

***

### StreamClientOptions

Options for constructing a [StreamClient](#streamclient).

#### Extends

* [`SessionSocketClientOptions`](#sessionsocketclientoptions)

#### Properties

| Property                                   | Type                                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Inherited from                                                                                  |
| ------------------------------------------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| <a id="tokenprovider-2" /> `tokenProvider` | [`TokenProvider`](#tokenprovider)       | Supplies the bearer token used to authenticate the connection.                                                                                                                                                                                                                                                                                                                                                                                                                  | [`SessionSocketClientOptions`](#sessionsocketclientoptions).[`tokenProvider`](#tokenprovider-1) |
| <a id="baseurl-3" /> `baseUrl?`            | `string`                                | Explicit base URL (e.g. `http://localhost:8080`). Overrides `environment`.                                                                                                                                                                                                                                                                                                                                                                                                      | [`SessionSocketClientOptions`](#sessionsocketclientoptions).[`baseUrl`](#baseurl-2)             |
| <a id="environment-4" /> `environment?`    | [`Environment`](#environment-2)         | Named environment to target. Defaults to `"production"`.                                                                                                                                                                                                                                                                                                                                                                                                                        | [`SessionSocketClientOptions`](#sessionsocketclientoptions).[`environment`](#environment-3)     |
| <a id="websocket-2" /> `webSocket?`        | [`WebSocketFactory`](#websocketfactory) | Custom WebSocket factory. Defaults to the global `WebSocket` (browsers, Node 22+). Supply one backed by the `ws` package on older Node.                                                                                                                                                                                                                                                                                                                                         | [`SessionSocketClientOptions`](#sessionsocketclientoptions).[`webSocket`](#websocket-1)         |
| <a id="apiversion-1" /> `apiVersion?`      | [`StreamApiVersion`](#streamapiversion) | Which stream endpoint to open. Defaults to `"v1"` (Inter-1). Pass `"v2"` to analyze the same session with the Inter-2 model at `/v2/stream/analyze`; everything else about the session is identical.                                                                                                                                                                                                                                                                            | -                                                                                               |
| <a id="model-1" /> `model?`                | [`StreamModel`](#streammodel-1)         | The Inter-2 model a `"v2"` session opens on, sent as the handshake's `model` query parameter. Defaults to `"inter-2"` when omitted. The credential must carry the scope for that model — `interhumanai.stream.inter-2` or `interhumanai.stream.inter-2-audio` — or the server refuses the session with `ih2003`. `"inter-2-deep"` is an upload model and is rejected here at construction; on `"v1"` the option is rejected too, since that endpoint offers no model selection. | -                                                                                               |

***

### StreamEnvelopeBase

Fields shared by every server→client envelope.

#### Extended by

* [`ConversationQualityUpdatedEvent`](#conversationqualityupdatedevent)
* [`CoverageDegradedEvent`](#coveragedegradedevent)
* [`CoverageDroppedEvent`](#coveragedroppedevent)
* [`EngagementUpdatedEvent`](#engagementupdatedevent)
* [`FeedbackGeneratedEvent`](#feedbackgeneratedevent)
* [`SessionClosingEvent`](#sessionclosingevent)
* [`SessionEndedEvent`](#sessionendedevent)
* [`SessionReadyEvent`](#sessionreadyevent)
* [`SessionUpdatedEvent`](#sessionupdatedevent)
* [`SignalDetectedEvent`](#signaldetectedevent)
* [`SignalEndedEvent`](#signalendedevent)
* [`SignalUpdatedEvent`](#signalupdatedevent)
* [`StreamErrorEvent`](#streamerrorevent)
* [`RealtimeSessionReadyEvent`](#realtimesessionreadyevent)
* [`RealtimeSessionUpdatedEvent`](#realtimesessionupdatedevent)
* [`RealtimeSignalDetectedEvent`](#realtimesignaldetectedevent)
* [`RealtimeSignalUpdatedEvent`](#realtimesignalupdatedevent)
* [`RealtimeRecommendationGeneratedEvent`](#realtimerecommendationgeneratedevent)

#### Properties

| Property                                     | Type     | Description                                                  |
| -------------------------------------------- | -------- | ------------------------------------------------------------ |
| <a id="timestamp-5" /> `timestamp`           | `string` | ISO 8601 timestamp identifying when the event occurred.      |
| <a id="correlation_id-6" /> `correlation_id` | `string` | Connection correlation id; quote it when contacting support. |

***

### 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

| Property                             | Type                              |
| ------------------------------------ | --------------------------------- |
| <a id="encoding" /> `encoding`       | `"pcm_s16le"`                     |
| <a id="sample_rate" /> `sample_rate` | [`PcmSampleRate`](#pcmsamplerate) |
| <a id="channels" /> `channels`       | `1`                               |

***

### SessionReadyConfigOptions

Supported session-config options advertised on `session.ready`.

#### Properties

| Property                                     | Type                                             | Description                                                                                                                       |
| -------------------------------------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| <a id="include" /> `include`                 | [`IncludeFlag`](#includeflag-1)\[]               | -                                                                                                                                 |
| <a id="goal_dimensions" /> `goal_dimensions` | [`GoalDimension`](#goaldimension-1)\[] \| `null` | `null` when the feedback feature is disabled.                                                                                     |
| <a id="model-3" /> `model`                   | [`StreamModel`](#streammodel-1)\[] \| `null`     | The models this deployment serves on `WS /v2/stream/analyze`; `null` on `WS /v1/stream/analyze`, which offers no model selection. |

***

### SessionReadyData

`session.ready` payload — session limits and supported config.

#### Properties

| Property                                                                         | Type                                                      | Description                                                                       |
| -------------------------------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------------------------------- |
| <a id="session_idle_timeout_seconds-1" /> `session_idle_timeout_seconds`         | `number`                                                  | Idle seconds tolerated before the server closes the session (`0` = disabled).     |
| <a id="session_max_duration_seconds-1" /> `session_max_duration_seconds`         | `number`                                                  | Maximum total session duration in seconds (`0` = disabled).                       |
| <a id="max_segment_duration_seconds-1" /> `max_segment_duration_seconds`         | `number` \| `null`                                        | Max probed duration of one inbound chunk, or `null` when only the size cap binds. |
| <a id="min_segment_size_bytes-1" /> `min_segment_size_bytes`                     | `number`                                                  | Minimum size in bytes of one inbound chunk.                                       |
| <a id="max_segment_size_bytes-1" /> `max_segment_size_bytes`                     | `number`                                                  | Maximum size in bytes of one inbound chunk.                                       |
| <a id="supported_session_config_options-1" /> `supported_session_config_options` | [`SessionReadyConfigOptions`](#sessionreadyconfigoptions) | -                                                                                 |

***

### SessionReadyEvent

Fields shared by every server→client envelope.

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                     | Type                                    | Description                                                  | Inherited from                                                                    |
| -------------------------------------------- | --------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="timestamp-6" /> `timestamp`           | `string`                                | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-7" /> `correlation_id` | `string`                                | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |
| <a id="type-6" /> `type`                     | `"session.ready"`                       | -                                                            | -                                                                                 |
| <a id="data-5" /> `data`                     | [`SessionReadyData`](#sessionreadydata) | -                                                            | -                                                                                 |

***

### SessionUpdatedData

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

#### Properties

| Property                                       | Type                                             | Description                                                                |
| ---------------------------------------------- | ------------------------------------------------ | -------------------------------------------------------------------------- |
| <a id="include-1" /> `include`                 | [`IncludeFlag`](#includeflag-1)\[]               | -                                                                          |
| <a id="goal_dimensions-1" /> `goal_dimensions` | [`GoalDimension`](#goaldimension-1)\[] \| `null` | -                                                                          |
| <a id="model-4" /> `model`                     | [`StreamModel`](#streammodel-1) \| `null`        | The model analyzing the session, on `WS /v2/stream/analyze`; `null` on v1. |

***

### SessionUpdatedEvent

Fields shared by every server→client envelope.

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                     | Type                                        | Description                                                  | Inherited from                                                                    |
| -------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="timestamp-7" /> `timestamp`           | `string`                                    | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-8" /> `correlation_id` | `string`                                    | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |
| <a id="type-7" /> `type`                     | `"session.updated"`                         | -                                                            | -                                                                                 |
| <a id="data-6" /> `data`                     | [`SessionUpdatedData`](#sessionupdateddata) | -                                                            | -                                                                                 |

***

### SessionClosingData

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

#### Properties

| Property                                         | Type     | Description                                                                                                                                                                                               |
| ------------------------------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="max_drain_seconds" /> `max_drain_seconds` | `number` | Maximum seconds the server will spend draining accepted work before it closes the session; `session.ended` arrives no later than this. The session closes earlier when the accepted work finishes sooner. |

***

### 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

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                     | Type                                        | Description                                                  | Inherited from                                                                    |
| -------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="timestamp-8" /> `timestamp`           | `string`                                    | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-9" /> `correlation_id` | `string`                                    | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |
| <a id="type-8" /> `type`                     | `"session.closing"`                         | -                                                            | -                                                                                 |
| <a id="data-7" /> `data`                     | [`SessionClosingData`](#sessionclosingdata) | -                                                            | -                                                                                 |

***

### SessionEndedData

`session.ended` payload — why the session ended.

#### Properties

| Property                   | Type                | Description                                                |
| -------------------------- | ------------------- | ---------------------------------------------------------- |
| <a id="reason" /> `reason` | `"client_shutdown"` | `client_shutdown` = the caller requested a graceful close. |

***

### 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

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                      | Type                                    | Description                                                  | Inherited from                                                                    |
| --------------------------------------------- | --------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="timestamp-9" /> `timestamp`            | `string`                                | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-10" /> `correlation_id` | `string`                                | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |
| <a id="type-9" /> `type`                      | `"session.ended"`                       | -                                                            | -                                                                                 |
| <a id="data-8" /> `data`                      | [`SessionEndedData`](#sessionendeddata) | -                                                            | -                                                                                 |

***

### SignalDetectedData

#### Properties

| Property                               | Type                                      | Description                                                                                                                |
| -------------------------------------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| <a id="signal_type-2" /> `signal_type` | [`SignalType`](#signaltype)               | -                                                                                                                          |
| <a id="start-4" /> `start`             | `number`                                  | Seconds, absolute session-cumulative time.                                                                                 |
| <a id="probability-2" /> `probability` | [`Probability`](#probability-4) \| `null` | -                                                                                                                          |
| <a id="rationale" /> `rationale`       | `string` \| `null`                        | -                                                                                                                          |
| <a id="modality-2" /> `modality`       | `string`\[]                               | Analysis modalities that detected this signal, naming the source of the evidence. For stream sessions this is `["video"]`. |

***

### SignalDetectedEvent

Fields shared by every server→client envelope.

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                      | Type                                        | Description                                                  | Inherited from                                                                    |
| --------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="timestamp-10" /> `timestamp`           | `string`                                    | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-11" /> `correlation_id` | `string`                                    | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |
| <a id="type-10" /> `type`                     | `"signal.detected"`                         | -                                                            | -                                                                                 |
| <a id="data-9" /> `data`                      | [`SignalDetectedData`](#signaldetecteddata) | -                                                            | -                                                                                 |

***

### SignalUpdatedData

#### Properties

| Property                               | Type                                      | Description                                                                                                          |
| -------------------------------------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| <a id="signal_type-3" /> `signal_type` | [`SignalType`](#signaltype)               | -                                                                                                                    |
| <a id="start-5" /> `start`             | `number`                                  | -                                                                                                                    |
| <a id="probability-3" /> `probability` | [`Probability`](#probability-4) \| `null` | -                                                                                                                    |
| <a id="rationale-1" /> `rationale`     | `string` \| `null`                        | -                                                                                                                    |
| <a id="modality-3" /> `modality`       | `string`\[]                               | Analyses whose evidence produced this signal. A change to this set is one of the things that emits `signal.updated`. |

***

### SignalUpdatedEvent

Fields shared by every server→client envelope.

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                      | Type                                      | Description                                                  | Inherited from                                                                    |
| --------------------------------------------- | ----------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="timestamp-11" /> `timestamp`           | `string`                                  | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-12" /> `correlation_id` | `string`                                  | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |
| <a id="type-11" /> `type`                     | `"signal.updated"`                        | -                                                            | -                                                                                 |
| <a id="data-10" /> `data`                     | [`SignalUpdatedData`](#signalupdateddata) | -                                                            | -                                                                                 |

***

### SignalEndedData

#### Properties

| Property                               | Type                        | Description                                |
| -------------------------------------- | --------------------------- | ------------------------------------------ |
| <a id="signal_type-4" /> `signal_type` | [`SignalType`](#signaltype) | -                                          |
| <a id="end-2" /> `end`                 | `number`                    | Seconds, absolute session-cumulative time. |

***

### SignalEndedEvent

Fields shared by every server→client envelope.

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                      | Type                                  | Description                                                  | Inherited from                                                                    |
| --------------------------------------------- | ------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="timestamp-12" /> `timestamp`           | `string`                              | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-13" /> `correlation_id` | `string`                              | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |
| <a id="type-12" /> `type`                     | `"signal.ended"`                      | -                                                            | -                                                                                 |
| <a id="data-11" /> `data`                     | [`SignalEndedData`](#signalendeddata) | -                                                            | -                                                                                 |

***

### EngagementUpdatedData

#### Properties

| Property                   | Type                                  |
| -------------------------- | ------------------------------------- |
| <a id="state" /> `state`   | [`EngagementLevel`](#engagementlevel) |
| <a id="start-6" /> `start` | `number`                              |

***

### EngagementUpdatedEvent

Fields shared by every server→client envelope.

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                      | Type                                              | Description                                                  | Inherited from                                                                    |
| --------------------------------------------- | ------------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="timestamp-13" /> `timestamp`           | `string`                                          | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-14" /> `correlation_id` | `string`                                          | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |
| <a id="type-13" /> `type`                     | `"engagement.updated"`                            | -                                                            | -                                                                                 |
| <a id="data-12" /> `data`                     | [`EngagementUpdatedData`](#engagementupdateddata) | -                                                            | -                                                                                 |

***

### ConversationQualityUpdatedData

#### Properties

| Property                       | Type                                                                                    | Description                                                                             |
| ------------------------------ | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| <a id="overall" /> `overall`   | [`ConversationQualityValues`](#conversationqualityvalues) \| `null`                     | Non-null when `conversation_quality_overall` was requested.                             |
| <a id="timeline" /> `timeline` | \| [`ConversationQualityTimelineEntry`](#conversationqualitytimelineentry)\[] \| `null` | Non-null when `conversation_quality_timeline` was requested and the period had signals. |

***

### ConversationQualityUpdatedEvent

Fields shared by every server→client envelope.

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                      | Type                                                                | Description                                                  | Inherited from                                                                    |
| --------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="timestamp-14" /> `timestamp`           | `string`                                                            | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-15" /> `correlation_id` | `string`                                                            | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |
| <a id="type-14" /> `type`                     | `"conversation_quality.updated"`                                    | -                                                            | -                                                                                 |
| <a id="data-13" /> `data`                     | [`ConversationQualityUpdatedData`](#conversationqualityupdateddata) | -                                                            | -                                                                                 |

***

### FeedbackGeneratedData

#### Properties

| Property                       | Type     | Description                                                                 |
| ------------------------------ | -------- | --------------------------------------------------------------------------- |
| <a id="feedback" /> `feedback` | `string` | Comma-separated relevant signal types observed since the previous emission. |

***

### FeedbackGeneratedEvent

Fields shared by every server→client envelope.

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                      | Type                                              | Description                                                  | Inherited from                                                                    |
| --------------------------------------------- | ------------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="timestamp-15" /> `timestamp`           | `string`                                          | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-16" /> `correlation_id` | `string`                                          | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |
| <a id="type-15" /> `type`                     | `"feedback.generated"`                            | -                                                            | -                                                                                 |
| <a id="data-14" /> `data`                     | [`FeedbackGeneratedData`](#feedbackgenerateddata) | -                                                            | -                                                                                 |

***

### CoverageDroppedRange

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

#### Properties

| Property                   | Type     |
| -------------------------- | -------- |
| <a id="start-7" /> `start` | `number` |
| <a id="end-3" /> `end`     | `number` |

***

### CoverageDroppedData

Payload of [CoverageDroppedEvent](#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

| Property                   | Type                                               |
| -------------------------- | -------------------------------------------------- |
| <a id="ranges" /> `ranges` | [`CoverageDroppedRange`](#coveragedroppedrange)\[] |

***

### CoverageDroppedEvent

Fields shared by every server→client envelope.

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                      | Type                                          | Description                                                  | Inherited from                                                                    |
| --------------------------------------------- | --------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="timestamp-16" /> `timestamp`           | `string`                                      | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-17" /> `correlation_id` | `string`                                      | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |
| <a id="type-16" /> `type`                     | `"coverage.dropped"`                          | -                                                            | -                                                                                 |
| <a id="data-15" /> `data`                     | [`CoverageDroppedData`](#coveragedroppeddata) | -                                                            | -                                                                                 |

***

### CoverageDegradedRange

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

#### Properties

| Property                   | Type     |
| -------------------------- | -------- |
| <a id="start-8" /> `start` | `number` |
| <a id="end-4" /> `end`     | `number` |

***

### CoverageDegradedData

Payload of [CoverageDegradedEvent](#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

| Property                     | Type                                                 | Description                                                                                                                                                                                                                                 |
| ---------------------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="ranges-1" /> `ranges` | [`CoverageDegradedRange`](#coveragedegradedrange)\[] | -                                                                                                                                                                                                                                           |
| <a id="reason-1" /> `reason` | `"video_gap"`                                        | Why the visual coverage was partial. Currently always `"video_gap"`: the windows' video packets covered materially less than the window span (e.g. a keyframe interval longer than the analysis window, as a static screen share produces). |

***

### 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

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                      | Type                                            | Description                                                  | Inherited from                                                                    |
| --------------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="timestamp-17" /> `timestamp`           | `string`                                        | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-18" /> `correlation_id` | `string`                                        | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |
| <a id="type-17" /> `type`                     | `"coverage.degraded"`                           | -                                                            | -                                                                                 |
| <a id="data-16" /> `data`                     | [`CoverageDegradedData`](#coveragedegradeddata) | -                                                            | -                                                                                 |

***

### StreamErrorData

#### Properties

| Property                       | Type               | Description                                              |
| ------------------------------ | ------------------ | -------------------------------------------------------- |
| <a id="code" /> `code`         | `string`           | Machine-readable error code (e.g. `"ih6002"`).           |
| <a id="message-3" /> `message` | `string`           | -                                                        |
| <a id="link-2" /> `link`       | `string` \| `null` | -                                                        |
| <a id="segment" /> `segment`   | `number` \| `null` | Inbound caller-chunk index when applicable, else `null`. |

***

### StreamErrorEvent

Fields shared by every server→client envelope.

#### Extends

* [`StreamEnvelopeBase`](#streamenvelopebase)

#### Properties

| Property                                      | Type                                  | Description                                                  | Inherited from                                                                    |
| --------------------------------------------- | ------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| <a id="timestamp-18" /> `timestamp`           | `string`                              | ISO 8601 timestamp identifying when the event occurred.      | [`StreamEnvelopeBase`](#streamenvelopebase).[`timestamp`](#timestamp-5)           |
| <a id="correlation_id-19" /> `correlation_id` | `string`                              | Connection correlation id; quote it when contacting support. | [`StreamEnvelopeBase`](#streamenvelopebase).[`correlation_id`](#correlation_id-6) |
| <a id="type-18" /> `type`                     | `"error"`                             | -                                                            | -                                                                                 |
| <a id="data-17" /> `data`                     | [`StreamErrorData`](#streamerrordata) | -                                                            | -                                                                                 |

***

### StreamSessionConfig

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

#### Properties

| Property                                        | Type                                   | Description                                                                                                                                                                                                                                                    |
| ----------------------------------------------- | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="include-2" /> `include?`                 | [`IncludeFlag`](#includeflag-1)\[]     | Conversation-quality sections to include in result messages.                                                                                                                                                                                                   |
| <a id="goal_dimensions-2" /> `goal_dimensions?` | [`GoalDimension`](#goaldimension-1)\[] | Goal dimensions for this session (drive periodic feedback).                                                                                                                                                                                                    |
| <a id="model-5" /> `model?`                     | [`StreamModel`](#streammodel-1)        | The model to analyze the session with, on `WS /v2/stream/analyze` only. Unlike `include`, this is session state: a frame that omits it keeps the model in force, and a different model is accepted only before the first media frame. Defaults to `"inter-2"`. |
| <a id="audio_format" /> `audio_format?`         | [`RawAudioFormat`](#rawaudioformat)    | Declares that the session's binary frames are raw PCM audio (see [RawAudioFormat](#rawaudioformat)). Requires `model: "inter-2-audio"` and is fixed once the first frame has been sent. Omit it to send WebM or fragmented-MP4 media.                          |

***

### 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

| Property                  | Type              |
| ------------------------- | ----------------- |
| <a id="type-19" /> `type` | `"session.close"` |

***

### StreamCloseInfo

Information about a closed stream connection.

#### Properties

| Property                     | Type     |
| ---------------------------- | -------- |
| <a id="code-1" /> `code`     | `number` |
| <a id="reason-2" /> `reason` | `string` |

***

### StreamEventMap

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

#### Properties

| Property                                                              | Type                                                                  | Description                                                        |
| --------------------------------------------------------------------- | --------------------------------------------------------------------- | ------------------------------------------------------------------ |
| <a id="sessionready-2" /> `session.ready`                             | [`SessionReadyEvent`](#sessionreadyevent)                             | -                                                                  |
| <a id="sessionupdated-1" /> `session.updated`                         | [`SessionUpdatedEvent`](#sessionupdatedevent)                         | -                                                                  |
| <a id="sessionclosing-1" /> `session.closing`                         | [`SessionClosingEvent`](#sessionclosingevent)                         | -                                                                  |
| <a id="sessionended-1" /> `session.ended`                             | [`SessionEndedEvent`](#sessionendedevent)                             | -                                                                  |
| <a id="signaldetected-1" /> `signal.detected`                         | [`SignalDetectedEvent`](#signaldetectedevent)                         | -                                                                  |
| <a id="signalupdated-1" /> `signal.updated`                           | [`SignalUpdatedEvent`](#signalupdatedevent)                           | -                                                                  |
| <a id="signalended-1" /> `signal.ended`                               | [`SignalEndedEvent`](#signalendedevent)                               | -                                                                  |
| <a id="engagementupdated" /> `engagement.updated`                     | [`EngagementUpdatedEvent`](#engagementupdatedevent)                   | -                                                                  |
| <a id="conversation_qualityupdated" /> `conversation_quality.updated` | [`ConversationQualityUpdatedEvent`](#conversationqualityupdatedevent) | -                                                                  |
| <a id="feedbackgenerated" /> `feedback.generated`                     | [`FeedbackGeneratedEvent`](#feedbackgeneratedevent)                   | -                                                                  |
| <a id="coveragedropped-1" /> `coverage.dropped`                       | [`CoverageDroppedEvent`](#coveragedroppedevent)                       | -                                                                  |
| <a id="coveragedegraded-1" /> `coverage.degraded`                     | [`CoverageDegradedEvent`](#coveragedegradedevent)                     | -                                                                  |
| <a id="error-1" /> `error`                                            | [`StreamErrorEvent`](#streamerrorevent)                               | -                                                                  |
| <a id="message-4" /> `message`                                        | [`StreamEvent`](#streamevent)                                         | Fires for every server→client envelope, regardless of type.        |
| <a id="open-2" /> `open`                                              | `void`                                                                | Fires once when the WebSocket connection opens.                    |
| <a id="close-5" /> `close`                                            | [`StreamCloseInfo`](#streamcloseinfo)                                 | Fires once when the connection closes.                             |
| <a id="socketerror-2" /> `socketError`                                | `Error`                                                               | Transport-level socket error (distinct from the `error` envelope). |

***

### 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

| Property                           | Modifier   | Type     |
| ---------------------------------- | ---------- | -------- |
| <a id="readystate" /> `readyState` | `readonly` | `number` |
| <a id="binarytype" /> `binaryType` | `public`   | `string` |

#### Methods

##### send()

```ts theme={null}
send(data): void;
```

###### Parameters

| Parameter | Type                                                                             |
| --------- | -------------------------------------------------------------------------------- |
| `data`    | `string` \| `Blob` \| `ArrayBufferLike` \| `ArrayBufferView`\<`ArrayBufferLike`> |

###### Returns

`void`

##### close()

```ts theme={null}
close(code?, reason?): void;
```

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `code?`   | `number` |
| `reason?` | `string` |

###### Returns

`void`

##### addEventListener()

```ts theme={null}
addEventListener(type, listener): void;
```

###### Parameters

| Parameter  | Type                |
| ---------- | ------------------- |
| `type`     | `string`            |
| `listener` | (`event`) => `void` |

###### Returns

`void`

##### removeEventListener()

```ts theme={null}
removeEventListener(type, listener): void;
```

###### Parameters

| Parameter  | Type                |
| ---------- | ------------------- |
| `type`     | `string`            |
| `listener` | (`event`) => `void` |

###### Returns

`void`

***

### Signal

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

#### Properties

| Property                               | Type                                      | Description                                                                                                                                                            |
| -------------------------------------- | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="type-20" /> `type`              | [`SignalType`](#signaltype)               | -                                                                                                                                                                      |
| <a id="start-9" /> `start`             | `number`                                  | Start time in seconds.                                                                                                                                                 |
| <a id="end-5" /> `end`                 | `number`                                  | End time in seconds.                                                                                                                                                   |
| <a id="probability-5" /> `probability` | [`Probability`](#probability-4) \| `null` | -                                                                                                                                                                      |
| <a id="rationale-2" /> `rationale`     | `string` \| `null`                        | -                                                                                                                                                                      |
| <a id="modality-4" /> `modality`       | `string`\[]                               | Analysis modalities that detected this signal, naming the source of the evidence. When several tracks detect the same signal, every contributing modality is included. |

***

### EngagementStateEntry

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

#### Properties

| Property                    | Type                                  |
| --------------------------- | ------------------------------------- |
| <a id="state-1" /> `state`  | [`EngagementLevel`](#engagementlevel) |
| <a id="start-10" /> `start` | `number`                              |
| <a id="end-6" /> `end`      | `number`                              |

***

### ConversationQualityValues

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

#### Properties

| Property                                 | Type     |
| ---------------------------------------- | -------- |
| <a id="quality_index" /> `quality_index` | `number` |
| <a id="clarity-1" /> `clarity`           | `number` |
| <a id="authority-1" /> `authority`       | `number` |
| <a id="energy-1" /> `energy`             | `number` |
| <a id="rapport-1" /> `rapport`           | `number` |
| <a id="learning-1" /> `learning`         | `number` |

***

### ConversationQualityTimelineEntry

Conversation-quality scores for one window of the timeline.

#### Properties

| Property                    | Type                                                      |
| --------------------------- | --------------------------------------------------------- |
| <a id="start-11" /> `start` | `number`                                                  |
| <a id="end-7" /> `end`      | `number`                                                  |
| <a id="values" /> `values`  | [`ConversationQualityValues`](#conversationqualityvalues) |

***

### ConversationQuality

Overall and time-varying conversation-quality scores.

#### Properties

| Property                         | Type                                                                       |
| -------------------------------- | -------------------------------------------------------------------------- |
| <a id="overall-1" /> `overall`   | [`ConversationQualityValues`](#conversationqualityvalues)                  |
| <a id="timeline-1" /> `timeline` | [`ConversationQualityTimelineEntry`](#conversationqualitytimelineentry)\[] |

***

### InteractionFeedback

Structured interaction feedback returned by the coach model.

#### Properties

| Property                                          | Type                                   |
| ------------------------------------------------- | -------------------------------------- |
| <a id="type-21" /> `type`                         | [`FeedbackType`](#feedbacktype)        |
| <a id="message-5" /> `message?`                   | `string` \| `null`                     |
| <a id="active_dimensions" /> `active_dimensions?` | [`GoalDimension`](#goaldimension-1)\[] |
| <a id="primary_signal" /> `primary_signal?`       | [`SignalType`](#signaltype) \| `null`  |
| <a id="reason-3" /> `reason?`                     | `string` \| `null`                     |

***

### AnalysisResult

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

#### Properties

| Property                                                | Type                                                    |
| ------------------------------------------------------- | ------------------------------------------------------- |
| <a id="signals" /> `signals`                            | [`Signal`](#signal)\[]                                  |
| <a id="engagement_state" /> `engagement_state`          | [`EngagementStateEntry`](#engagementstateentry)\[]      |
| <a id="feedback-1" /> `feedback?`                       | [`InteractionFeedback`](#interactionfeedback) \| `null` |
| <a id="conversation_quality" /> `conversation_quality?` | [`ConversationQuality`](#conversationquality) \| `null` |

***

### AnalyzeUploadInput

Arguments for [UploadClient.analyze](#analyze).

#### Properties

| Property                                              | Type                                   | Description                                                                                                                                     |
| ----------------------------------------------------- | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="file" /> `file`                                | [`VideoInput`](#videoinput)            | The video file to analyze (mp4/avi/mov/mkv/mpeg-ts/webm, ≥3s, ≤32MB).                                                                           |
| <a id="filename" /> `filename?`                       | `string`                               | Filename used when `file` is a `Blob` without a name. Defaults to `"video"`.                                                                    |
| <a id="include-3" /> `include?`                       | [`IncludeFlag`](#includeflag-1)\[]     | Optional response sections to include. When omitted, conversation-quality scores are not returned.                                              |
| <a id="goaldimensions" /> `goalDimensions?`           | [`GoalDimension`](#goaldimension-1)\[] | Optional goal dimensions for this interaction. Supplying at least one triggers interaction feedback. Ignored when `conversationContext` is set. |
| <a id="conversationcontext" /> `conversationContext?` | `string`                               | Optional free-text scenario description. When set, it is the sole source of context for feedback generation and `goalDimensions` is ignored.    |
| <a id="signal-1" /> `signal?`                         | `AbortSignal`                          | Optional `AbortSignal` to cancel the request.                                                                                                   |

***

### 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

| Property                                         | Type                                  | Description                                                     |
| ------------------------------------------------ | ------------------------------------- | --------------------------------------------------------------- |
| <a id="index" /> `index`                         | `number`                              | Zero-based position of the window in the file.                  |
| <a id="start_seconds" /> `start_seconds`         | `number`                              | Where the window starts, in seconds from the start of the file. |
| <a id="end_seconds" /> `end_seconds`             | `number`                              | Where the window ends, in seconds from the start of the file.   |
| <a id="engagement_status" /> `engagement_status` | [`EngagementLevel`](#engagementlevel) | -                                                               |
| <a id="signals-1" /> `signals`                   | [`Signal`](#signal)\[]                | -                                                               |

***

### UploadJobResult

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

#### Properties

| Property                                       | Type                                     | Description                                 |
| ---------------------------------------------- | ---------------------------------------- | ------------------------------------------- |
| <a id="duration_seconds" /> `duration_seconds` | `number`                                 | Length of the analyzed media, in seconds.   |
| <a id="window_seconds" /> `window_seconds`     | `number`                                 | Length of each analysis window, in seconds. |
| <a id="windows" /> `windows`                   | [`UploadJobWindow`](#uploadjobwindow)\[] | Per-window analyses, in file order.         |

***

### UploadJobError

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

#### Properties

| Property                                       | Type               | Description                  |
| ---------------------------------------------- | ------------------ | ---------------------------- |
| <a id="error_id-1" /> `error_id`               | `string`           | Machine-readable error code. |
| <a id="correlation_id-20" /> `correlation_id?` | `string` \| `null` | -                            |
| <a id="link-3" /> `link?`                      | `string` \| `null` | -                            |
| <a id="message-6" /> `message?`                | `string` \| `null` | -                            |

***

### 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

| Property                           | Type                                            | Description                                                        |
| ---------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------ |
| <a id="job_id" /> `job_id`         | `string`                                        | Identifier of the job; use it with [UploadClient.getJob](#getjob). |
| <a id="status-1" /> `status`       | [`UploadJobStatus`](#uploadjobstatus)           | -                                                                  |
| <a id="model-6" /> `model`         | [`UploadModel`](#uploadmodel-1)                 | -                                                                  |
| <a id="created_at" /> `created_at` | `string`                                        | When the job was accepted, as an ISO 8601 UTC timestamp.           |
| <a id="expires_at" /> `expires_at` | `string`                                        | When the job stops being readable, as an ISO 8601 UTC timestamp.   |
| <a id="status_url" /> `status_url` | `string`                                        | Path of the status resource, relative to the API base URL.         |
| <a id="result" /> `result?`        | [`UploadJobResult`](#uploadjobresult) \| `null` | -                                                                  |
| <a id="error-2" /> `error?`        | [`UploadJobError`](#uploadjoberror) \| `null`   | -                                                                  |

***

### SubmitUploadJobInput

Arguments for [UploadClient.submit](#submit).

#### Properties

| Property                              | Type                            | Description                                                                                                                                                                                                                                                                                 |
| ------------------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="file-1" /> `file`              | [`VideoInput`](#videoinput)     | The file to analyze. For `inter-2-audio`: wav, flac, mp3, m4a, ogg, or a webm or mp4 with an audio track — at least 3 seconds of media, at most 32 MB, and no longer than the deployment's maximum duration (30 minutes by default; a longer file rejects with `ih4004`).                   |
| <a id="filename-1" /> `filename?`     | `string`                        | Filename used when `file` is a `Blob` without a name. Defaults to `"video"`.                                                                                                                                                                                                                |
| <a id="model-7" /> `model`            | [`UploadModel`](#uploadmodel-1) | The Inter-2 model to analyze with. `inter-2` and `inter-2-deep` are valid values the route does not serve yet and reject with `ih4020`.                                                                                                                                                     |
| <a id="waitseconds" /> `waitSeconds?` | `number`                        | How long, in seconds, the API may hold the request open waiting for the job to finish. `0` (the default) answers with the queued envelope at once; when the job finishes within the wait, the envelope comes back terminal. The deployment bounds it; a larger value rejects with `ih4005`. |
| <a id="signal-2" /> `signal?`         | `AbortSignal`                   | Optional `AbortSignal` to cancel the request.                                                                                                                                                                                                                                               |

***

### WaitForJobOptions

Options for [UploadClient.waitForJob](#waitforjob).

#### Properties

| Property                                    | Type          | Description                                                                                                                                   |
| ------------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="timeoutms" /> `timeoutMs?`           | `number`      | Give up after this many milliseconds and reject with [UploadJobTimeoutError](#uploadjobtimeouterror). Omit to wait until the job is terminal. |
| <a id="pollintervalms" /> `pollIntervalMs?` | `number`      | Milliseconds between status reads. Defaults to 2000.                                                                                          |
| <a id="signal-3" /> `signal?`               | `AbortSignal` | Optional `AbortSignal` that stops polling and rejects each read.                                                                              |

***

### UploadClientOptions

Options for constructing an [UploadClient](#uploadclient).

#### Properties

| Property                                   | Type                                                                                         | Description                                                                |
| ------------------------------------------ | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| <a id="tokenprovider-3" /> `tokenProvider` | [`TokenProvider`](#tokenprovider)                                                            | Supplies the bearer token attached to each request.                        |
| <a id="baseurl-4" /> `baseUrl?`            | `string`                                                                                     | Explicit base URL (e.g. `http://localhost:8080`). Overrides `environment`. |
| <a id="environment-5" /> `environment?`    | [`Environment`](#environment-2)                                                              | Named environment to target. Defaults to `"production"`.                   |
| <a id="fetch-2" /> `fetch?`                | \{ (`input`, `init?`): `Promise`\<`Response`>; (`input`, `init?`): `Promise`\<`Response`>; } | Custom `fetch` implementation. Defaults to the global `fetch`.             |

## Type Aliases

### Environment

```ts theme={null}
type Environment = "production" | "staging";
```

A named Interhuman API environment.

***

### RealtimeClientOptions

```ts theme={null}
type RealtimeClientOptions = SessionSocketClientOptions;
```

Options for constructing a [RealtimeClient](#realtimeclient).

***

### AnalysisGroup

```ts theme={null}
type AnalysisGroup = "visual" | "audio";
```

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

```ts theme={null}
type RealtimeRecommendationFrequency = "high" | "medium" | "low";
```

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

```ts theme={null}
type RealtimeEvent = 
  | RealtimeSessionReadyEvent
  | RealtimeSessionUpdatedEvent
  | SessionClosingEvent
  | SessionEndedEvent
  | RealtimeSignalDetectedEvent
  | RealtimeSignalUpdatedEvent
  | SignalEndedEvent
  | TranscriptGeneratedEvent
  | RealtimeRecommendationGeneratedEvent
  | CoverageDroppedEvent
  | CoverageDegradedEvent
  | StreamErrorEvent;
```

Discriminated union of every realtime server→client envelope.

***

### VideoChunk

```ts theme={null}
type VideoChunk = Uint8Array | ArrayBuffer | ArrayBufferView | Blob;
```

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

***

### AudioFrame

```ts theme={null}
type AudioFrame = Uint8Array | ArrayBuffer | ArrayBufferView | Blob;
```

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

***

### Listener

```ts theme={null}
type Listener<T> = (payload) => void;
```

An event handler registered via `on`/`once`.

#### Type Parameters

| Type Parameter |
| -------------- |
| `T`            |

#### Parameters

| Parameter | Type |
| --------- | ---- |
| `payload` | `T`  |

#### Returns

`void`

***

### StreamApiVersion

```ts theme={null}
type StreamApiVersion = "v1" | "v2";
```

Which stream endpoint a [StreamClient](#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

```ts theme={null}
type StreamModel = "inter-2" | "inter-2-audio" | "inter-2-deep";
```

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](#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

```ts theme={null}
type PcmSampleRate = 16000 | 24000;
```

Sample rates accepted for raw PCM frames.

***

### StreamEvent

```ts theme={null}
type StreamEvent = 
  | SessionReadyEvent
  | SessionUpdatedEvent
  | SessionClosingEvent
  | SessionEndedEvent
  | SignalDetectedEvent
  | SignalUpdatedEvent
  | SignalEndedEvent
  | EngagementUpdatedEvent
  | ConversationQualityUpdatedEvent
  | FeedbackGeneratedEvent
  | CoverageDroppedEvent
  | CoverageDegradedEvent
  | StreamErrorEvent;
```

Discriminated union of every server→client envelope.

***

### WebSocketFactory

```ts theme={null}
type WebSocketFactory = (url, protocols?) => WebSocketLike;
```

Constructs a [WebSocketLike](#websocketlike) from a URL and optional subprotocols.

#### Parameters

| Parameter    | Type                    |
| ------------ | ----------------------- |
| `url`        | `string`                |
| `protocols?` | `string` \| `string`\[] |

#### Returns

[`WebSocketLike`](#websocketlike)

***

### ScopeValue

```ts theme={null}
type ScopeValue = 
  | "interhumanai.upload"
  | "interhumanai.stream"
  | "interhumanai.realtime"
  | "interhumanai.upload.inter-2"
  | "interhumanai.upload.inter-2-audio"
  | "interhumanai.upload.inter-2-deep"
  | "interhumanai.stream.inter-2"
  | "interhumanai.stream.inter-2-audio";
```

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

```ts theme={null}
type SignalType = 
  | "agreement"
  | "confidence"
  | "confusion"
  | "disagreement"
  | "disengagement"
  | "engagement"
  | "frustration"
  | "hesitation"
  | "interest"
  | "skepticism"
  | "stress"
  | "tension"
  | "uncertainty";
```

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

```ts theme={null}
type Probability = "high" | "medium" | "low";
```

Confidence level attached to a detected signal.

***

### EngagementLevel

```ts theme={null}
type EngagementLevel = "engaged" | "neutral" | "disengaged";
```

Engagement state of the analyzed subject.

***

### GoalDimension

```ts theme={null}
type GoalDimension = "clarity" | "authority" | "energy" | "rapport" | "learning";
```

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

***

### IncludeFlag

```ts theme={null}
type IncludeFlag = "conversation_quality_overall" | "conversation_quality_timeline";
```

Optional response sections the caller may request.

***

### FeedbackType

```ts theme={null}
type FeedbackType = "feedback" | "no_feedback";
```

Discriminator for the structured interaction-feedback result.

***

### VideoInput

```ts theme={null}
type VideoInput = 
  | Blob
  | {
  data: Uint8Array | ArrayBuffer | Blob;
  filename?: string;
  contentType?: string;
};
```

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

```ts theme={null}
{
  data: Uint8Array | ArrayBuffer | Blob;
  filename?: string;
  contentType?: string;
}
```

###### data

```ts theme={null}
data: Uint8Array | ArrayBuffer | Blob;
```

Raw video bytes.

###### filename?

```ts theme={null}
optional filename?: string;
```

Filename to report in the multipart part, e.g. `"clip.mp4"`.

###### contentType?

```ts theme={null}
optional contentType?: string;
```

MIME type, e.g. `"video/mp4"`.

***

### UploadModel

```ts theme={null}
type UploadModel = "inter-2" | "inter-2-audio" | "inter-2-deep";
```

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](#interhumanapierror) whose `errorId` is `ih4020`.

***

### UploadJobStatus

```ts theme={null}
type UploadJobStatus = "queued" | "running" | "completed" | "failed";
```

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

```ts theme={null}
const HTTP_BASE_URLS: Record<Environment, string>;
```

HTTP base URLs per named environment.

***

### AnalysisGroup

```ts theme={null}
AnalysisGroup: {
  Visual: "visual";
  Audio: "audio";
};
```

Named analysis-group constants.

#### Type Declaration

##### Visual

```ts theme={null}
readonly Visual: "visual" = "visual";
```

The visual-signals track.

##### Audio

```ts theme={null}
readonly Audio: "audio" = "audio";
```

The audio tracks.

***

### RealtimeRecommendationFrequency

```ts theme={null}
RealtimeRecommendationFrequency: {
  High: "high";
  Medium: "medium";
  Low: "low";
};
```

Named recommendation-frequency constants.

#### Type Declaration

##### High

```ts theme={null}
readonly High: "high" = "high";
```

A recommendation runs every 10 seconds of analyzed video.

##### Medium

```ts theme={null}
readonly Medium: "medium" = "medium";
```

A recommendation runs every 20 seconds of analyzed video.

##### Low

```ts theme={null}
readonly Low: "low" = "low";
```

A recommendation runs every 30 seconds of analyzed video.

***

### SDK\_NAME

```ts theme={null}
const SDK_NAME: "typescript" = "typescript";
```

This SDK's canonical name in API telemetry.

***

### SDK\_VERSION

```ts theme={null}
const SDK_VERSION: string = packageJson.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

```ts theme={null}
const SDK_HEADER_NAME: "X-Interhuman-SDK" = "X-Interhuman-SDK";
```

HTTP header carrying the SDK identity.

***

### STREAM\_ENDPOINT\_PATHS

```ts theme={null}
const STREAM_ENDPOINT_PATHS: Readonly<Record<StreamApiVersion, string>>;
```

Endpoint path opened for each [StreamApiVersion](#streamapiversion).

***

### StreamModel

```ts theme={null}
StreamModel: {
  Inter2: "inter-2";
  Inter2Audio: "inter-2-audio";
  Inter2Deep: "inter-2-deep";
};
```

Named stream-model constants.

#### Type Declaration

##### Inter2

```ts theme={null}
readonly Inter2: "inter-2" = "inter-2";
```

##### Inter2Audio

```ts theme={null}
readonly Inter2Audio: "inter-2-audio" = "inter-2-audio";
```

##### Inter2Deep

```ts theme={null}
readonly Inter2Deep: "inter-2-deep" = "inter-2-deep";
```

***

### WS\_READY\_STATE

```ts theme={null}
const WS_READY_STATE: {
  CONNECTING: 0;
  OPEN: 1;
  CLOSING: 2;
  CLOSED: 3;
};
```

`readyState` constants, mirrored from the WHATWG WebSocket spec.

#### Type Declaration

##### CONNECTING

```ts theme={null}
readonly CONNECTING: 0 = 0;
```

##### OPEN

```ts theme={null}
readonly OPEN: 1 = 1;
```

##### CLOSING

```ts theme={null}
readonly CLOSING: 2 = 2;
```

##### CLOSED

```ts theme={null}
readonly CLOSED: 3 = 3;
```

***

### Scope

```ts theme={null}
const Scope: {
  Upload: "interhumanai.upload";
  Stream: "interhumanai.stream";
  Realtime: "interhumanai.realtime";
  UploadInter2: "interhumanai.upload.inter-2";
  UploadInter2Audio: "interhumanai.upload.inter-2-audio";
  UploadInter2Deep: "interhumanai.upload.inter-2-deep";
  StreamInter2: "interhumanai.stream.inter-2";
  StreamInter2Audio: "interhumanai.stream.inter-2-audio";
};
```

Named scope constants.

#### Type Declaration

##### Upload

```ts theme={null}
readonly Upload: "interhumanai.upload" = "interhumanai.upload";
```

Grants access to `POST /v1/upload/analyze` (Inter-1).

##### Stream

```ts theme={null}
readonly Stream: "interhumanai.stream" = "interhumanai.stream";
```

Grants access to `WS /v1/stream/analyze` (Inter-1).

##### Realtime

```ts theme={null}
readonly Realtime: "interhumanai.realtime" = "interhumanai.realtime";
```

Grants access to `WS /v0/realtime/analyze`.

##### UploadInter2

```ts theme={null}
readonly UploadInter2: "interhumanai.upload.inter-2" = "interhumanai.upload.inter-2";
```

Grants `POST /v2/upload/analyze` with `model: "inter-2"`, and reading the account's jobs.

##### UploadInter2Audio

```ts theme={null}
readonly UploadInter2Audio: "interhumanai.upload.inter-2-audio" = "interhumanai.upload.inter-2-audio";
```

Grants `POST /v2/upload/analyze` with `model: "inter-2-audio"`, and reading the account's jobs.

##### UploadInter2Deep

```ts theme={null}
readonly UploadInter2Deep: "interhumanai.upload.inter-2-deep" = "interhumanai.upload.inter-2-deep";
```

Grants `POST /v2/upload/analyze` with `model: "inter-2-deep"`, and reading the account's jobs.

##### StreamInter2

```ts theme={null}
readonly StreamInter2: "interhumanai.stream.inter-2" = "interhumanai.stream.inter-2";
```

Grants `WS /v2/stream/analyze` with `model: "inter-2"`.

##### StreamInter2Audio

```ts theme={null}
readonly StreamInter2Audio: "interhumanai.stream.inter-2-audio" = "interhumanai.stream.inter-2-audio";
```

Grants `WS /v2/stream/analyze` with `model: "inter-2-audio"`.

***

### GoalDimension

```ts theme={null}
GoalDimension: {
  Clarity: "clarity";
  Authority: "authority";
  Energy: "energy";
  Rapport: "rapport";
  Learning: "learning";
};
```

Named goal-dimension constants.

#### Type Declaration

##### Clarity

```ts theme={null}
readonly Clarity: "clarity" = "clarity";
```

##### Authority

```ts theme={null}
readonly Authority: "authority" = "authority";
```

##### Energy

```ts theme={null}
readonly Energy: "energy" = "energy";
```

##### Rapport

```ts theme={null}
readonly Rapport: "rapport" = "rapport";
```

##### Learning

```ts theme={null}
readonly Learning: "learning" = "learning";
```

***

### IncludeFlag

```ts theme={null}
IncludeFlag: {
  ConversationQualityOverall: "conversation_quality_overall";
  ConversationQualityTimeline: "conversation_quality_timeline";
};
```

Named include-flag constants.

#### Type Declaration

##### ConversationQualityOverall

```ts theme={null}
readonly ConversationQualityOverall: "conversation_quality_overall" = "conversation_quality_overall";
```

##### ConversationQualityTimeline

```ts theme={null}
readonly ConversationQualityTimeline: "conversation_quality_timeline" = "conversation_quality_timeline";
```

***

### UploadModel

```ts theme={null}
UploadModel: {
  Inter2: "inter-2";
  Inter2Audio: "inter-2-audio";
  Inter2Deep: "inter-2-deep";
};
```

Named upload-model constants.

#### Type Declaration

##### Inter2

```ts theme={null}
readonly Inter2: "inter-2" = "inter-2";
```

##### Inter2Audio

```ts theme={null}
readonly Inter2Audio: "inter-2-audio" = "inter-2-audio";
```

##### Inter2Deep

```ts theme={null}
readonly Inter2Deep: "inter-2-deep" = "inter-2-deep";
```

***

### DEFAULT\_JOB\_POLL\_INTERVAL\_MS

```ts theme={null}
const DEFAULT_JOB_POLL_INTERVAL_MS: 2000 = 2000;
```

Default interval between status reads in [UploadClient.waitForJob](#waitforjob).

## Functions

### resolveHttpBaseUrl()

```ts theme={null}
function resolveHttpBaseUrl(options): string;
```

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

| Parameter              | Type                                                                        |
| ---------------------- | --------------------------------------------------------------------------- |
| `options`              | \{ `baseUrl?`: `string`; `environment?`: [`Environment`](#environment-2); } |
| `options.baseUrl?`     | `string`                                                                    |
| `options.environment?` | [`Environment`](#environment-2)                                             |

#### Returns

`string`

***

### httpToWsBaseUrl()

```ts theme={null}
function httpToWsBaseUrl(httpBaseUrl): string;
```

Derive the WebSocket origin from an HTTP base URL: `https`→`wss`,
`http`→`ws`. Any path on the base URL is preserved (so a proxy mount
point survives), with the trailing slash trimmed.

#### Parameters

| Parameter     | Type     |
| ------------- | -------- |
| `httpBaseUrl` | `string` |

#### Returns

`string`

***

### sdkHeaderValue()

```ts theme={null}
function sdkHeaderValue(): string;
```

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

#### Returns

`string`

***

### isTerminal()

```ts theme={null}
function isTerminal(job): boolean;
```

Whether a job has finished, successfully or not.

#### Parameters

| Parameter | Type                      |
| --------- | ------------------------- |
| `job`     | [`UploadJob`](#uploadjob) |

#### Returns

`boolean`
