Skip to navigation

Create a realtime client secret

Creates a short-lived client secret for opening a Realtime Voice API session from a web page. Call this endpoint from your server with your API key, then give the returned value and url to the page. The page never receives your API key.

The page opens url with two WebSocket subprotocols, empirio.realtime.v1 and empirio-token.<value>:

const ws = new WebSocket(secret.url, ["empirio.realtime.v1", `empirio-token.${secret.value}`]);

A client secret works only for the model it was created for. It can open sessions until expires_at, and a session that is already open continues after that time. Sessions bill to your account and appear in usage under the API key that created the secret. Deactivating or deleting that key stops its client secrets from opening new sessions. Creating a client secret counts as one request toward your account rate limit.

Authentication

AuthorizationBearer

Pass your EmpirioLabs API key as a bearer token. The Anthropic-style x-api-key header is also accepted on every endpoint.

Request

This endpoint expects an object.
modelstringOptional

The realtime model the secret is for. Required unless session.model is set.

expires_afterobjectOptional
How long the secret can open new sessions.
sessionobjectOptional

Accepted for clients that send the model as session.model. Other session settings are refused here; the page sends them in a session.update event after the socket opens.

Response

The client secret and the WebSocket URL to open with it.
objectenumOptional
Allowed values:
valuestringOptional

The client secret. The page offers it as the empirio-token.<value> subprotocol.

expires_atintegerOptional
Unix time in seconds after which the secret can no longer open a session.
modelstringOptional
The model the secret is for.
urlstringOptional
The WebSocket URL to open with the secret.
sessionobjectOptional

The session the secret is for: a realtime session with its model, or, for a live transcription model, a transcription session with the model in audio.input.transcription.model. Send the session settings in a session.update event after the socket opens.

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
429
Too Many Requests Error