io.enterpriseai.resources.RealtimeClient
Source: sdks/java/enterprise-ai-java/src/main/java/io/enterpriseai/resources/RealtimeClient.java. Back to the Java SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Class RealtimeClient
Realtime voice sessions (LiveKit) and WebSocket events.
Constructor RealtimeClient
RealtimeClient(Transport transport)
Creates the client on the shared transport; EnterpriseAIClient builds it and exposes it through the accessor of the same name.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
transport | Transport | yes | Transport shared by the sub-clients of one client. |
RealtimeClient.connect
CompletableFuture<WebSocket> connect(String sessionId, WebSocket.Listener listener)
Opens WebSocket /v1/realtime/ws/{session_id} with a new single use ws_token requested by #createToken before every connection, so a reconnection never reuses a token. Events are JSON text frames such as session.update, input_audio.append, transcript.delta, response.audio.delta, usage.update and error.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
sessionId | String | yes | Id of the voice session; a ws_token is requested for it before connecting. | |
listener | WebSocket.Listener | yes | WebSocket.Listener that receives the JSON text frames of the session. |
Returns: CompletableFuture<WebSocket>. A CompletableFuture completed with the open WebSocket; IllegalStateException when the server returns no ws_token.
Raises: IllegalStateException.
RealtimeClient.consents
JsonNode consents(String sessionId)
List the consents of a session. Consents recorded for the session, in capture order, with their revocation when revoked. One page only.
Route: /v1/realtime/sessions/{session_id}/consents (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
sessionId | String | yes | Identifier (UUID) of the realtime session. |
Returns: JsonNode. Decoded JSON answer of the operation "List the consents of a session".
Raises: the typed errors of the transport (Errors).
RealtimeClient.createSession
JsonNode createSession(Object body)
Open a realtime session. Opens a session (201) and returns it with session_id, livekit (url, token, room, configured) and the WebSocket access (ws_url, ws_token, ws_token_expires_at). Needs tenant_admin, developer or agent. Checks: pipeline is echo or stt (400 invalid_request); config.vad and config.dlp_mode are valid (422 parameter_invalid); an agent caller acts for on_behalf_of, a user may only open a session for itself (403 identity_mismatch); LiveKit credentials are configured; the policy realtime.session.create is evaluated. The room defaults to a name derived from the tenant and the session. Audited as realtime.session.create.
Route: /v1/realtime/sessions (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Room, pipeline, token lifetime, configuration, agent and user acted for. |
Returns: JsonNode. Decoded JSON answer of the operation "Open a realtime session".
Raises: the typed errors of the transport (Errors).
RealtimeClient.createSession
JsonNode createSession(Object body, RequestOptions options)
Open a realtime session. Opens a session (201) and returns it with session_id, livekit (url, token, room, configured) and the WebSocket access (ws_url, ws_token, ws_token_expires_at). Needs tenant_admin, developer or agent. Checks: pipeline is echo or stt (400 invalid_request); config.vad and config.dlp_mode are valid (422 parameter_invalid); an agent caller acts for on_behalf_of, a user may only open a session for itself (403 identity_mismatch); LiveKit credentials are configured; the policy realtime.session.create is evaluated. The room defaults to a name derived from the tenant and the session. Audited as realtime.session.create.
Route: /v1/realtime/sessions (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Room, pipeline, token lifetime, configuration, agent and user acted for. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Open a realtime session".
Raises: the typed errors of the transport (Errors).
RealtimeClient.createToken
JsonNode createToken(String id)
Get a new WebSocket token. New single use WebSocket token for an open session (reconnection), read under RLS: ws_url, ws_token, ws_token_expires_at. 409 session_ended; 404 not_found. Needs tenant_admin, developer or agent. Audited as realtime.session.token.
Route: /v1/realtime/sessions/{session_id}/token (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id | String | yes | Identifier (UUID) of the realtime session. |
Returns: JsonNode. Decoded JSON answer of the operation "Get a new WebSocket token".
Raises: the typed errors of the transport (Errors).
RealtimeClient.endSession
JsonNode endSession(String id)
End a realtime session. Ends the session and records its usage event (voice_live: audio seconds, input and output tokens, measured cost). Ending a session already ended returns it unchanged. Needs tenant_admin, developer or agent. Audited as realtime.session.end.
Route: /v1/realtime/sessions/{session_id}/end (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id | String | yes | Identifier (UUID) of the realtime session. |
Returns: JsonNode. Decoded JSON answer of the operation "End a realtime session".
Raises: the typed errors of the transport (Errors).
RealtimeClient.getSession
JsonNode getSession(String id)
Get a realtime session. Returns the session: room, identities, agent, pipeline, configuration, status, audio seconds, tokens and usage. 404 not_found.
Route: /v1/realtime/sessions/{session_id} (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id | String | yes | Identifier (UUID) of the realtime session. |
Returns: JsonNode. Decoded JSON answer of the operation "Get a realtime session".
Raises: the typed errors of the transport (Errors).
RealtimeClient.grantConsent
JsonNode grantConsent(String sessionId, Object body)
Record a participant consent. Consent of one participant (purpose, recording, transcription, retention, method), captured by the caller (201). The participant defaults to the participant of the session. The method must be verbal, click, written or api (422 parameter_invalid); the session must not be ended (409 session_ended); the policy realtime.consent.record is evaluated. Needs tenant_admin, developer or agent. Audited as realtime.consent.record.
Route: /v1/realtime/sessions/{session_id}/consents (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
sessionId | String | yes | Identifier (UUID) of the realtime session. | |
body | Object | yes | The consent of the participant. |
Returns: JsonNode. Decoded JSON answer of the operation "Record a participant consent".
Raises: the typed errors of the transport (Errors).
RealtimeClient.grantConsent
JsonNode grantConsent(String sessionId, Object body, RequestOptions options)
Record a participant consent. Consent of one participant (purpose, recording, transcription, retention, method), captured by the caller (201). The participant defaults to the participant of the session. The method must be verbal, click, written or api (422 parameter_invalid); the session must not be ended (409 session_ended); the policy realtime.consent.record is evaluated. Needs tenant_admin, developer or agent. Audited as realtime.consent.record.
Route: /v1/realtime/sessions/{session_id}/consents (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
sessionId | String | yes | Identifier (UUID) of the realtime session. | |
body | Object | yes | The consent of the participant. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Record a participant consent".
Raises: the typed errors of the transport (Errors).
RealtimeClient.revokeConsent
JsonNode revokeConsent(String sessionId, String consentId)
Revoke a consent. Revocation takes effect on the next audio event: transcription and recording are refused again. A consent already revoked or unknown answers 404 not_found. Needs tenant_admin, developer or agent. Audited as realtime.consent.revoke.
Route: /v1/realtime/sessions/{session_id}/consents/{consent_id}/revoke (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
sessionId | String | yes | Identifier (UUID) of the realtime session. | |
consentId | String | yes | Identifier (UUID) of the consent. |
Returns: JsonNode. Decoded JSON answer of the operation "Revoke a consent".
Raises: the typed errors of the transport (Errors).
RealtimeClient.revokeConsent
JsonNode revokeConsent(String sessionId, String consentId, RequestOptions options)
Revoke a consent. Revocation takes effect on the next audio event: transcription and recording are refused again. A consent already revoked or unknown answers 404 not_found. Needs tenant_admin, developer or agent. Audited as realtime.consent.revoke.
Route: /v1/realtime/sessions/{session_id}/consents/{consent_id}/revoke (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
sessionId | String | yes | Identifier (UUID) of the realtime session. | |
consentId | String | yes | Identifier (UUID) of the consent. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Revoke a consent".
Raises: the typed errors of the transport (Errors).
RealtimeClient.transcripts
JsonNode transcripts(String sessionId)
List the transcripts of a session. Stored transcripts, already filtered by the DLP (the raw transcript is never stored), with turn, consent, participant, DLP findings and expiry. Needs tenant_admin, developer, auditor or security_officer.
Route: /v1/realtime/sessions/{session_id}/transcripts (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
sessionId | String | yes | Identifier (UUID) of the realtime session. |
Returns: JsonNode. Decoded JSON answer of the operation "List the transcripts of a session".
Raises: the typed errors of the transport (Errors).
RealtimeClient.turns
JsonNode turns(String sessionId)
List the turns of a session. Turns with the participant, the user, the agent, the trace id, the status (a barge-in records cancelled) and the measured latency, in order. One page only.
Route: /v1/realtime/sessions/{session_id}/turns (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
sessionId | String | yes | Identifier (UUID) of the realtime session. |
Returns: JsonNode. Decoded JSON answer of the operation "List the turns of a session".
Raises: the typed errors of the transport (Errors).