POST/realtime/client_secrets

Create client secret

Create a Realtime client secret with an associated session configuration.

Client secrets are short-lived tokens that can be passed to a client app, such as a web frontend or mobile client, which grants access to the Realtime API without leaking your main API key. You can configure a custom TTL for each client secret.

You can also attach session configuration options to the client secret, which will be applied to any sessions created using that client secret, but these can also be overridden by the client connection.

Learn more about authentication with client secrets over WebRTC.

Returns the created client secret and the effective session object. The client secret is a string that looks like ek_1234.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

2 body fields

Create a client secret with the given session configuration.

expires_afterobjectoptional
Configuration for the client secret expiration. Expiration refers to the time after which a client secret will no longer be valid for creating sessions. The session itself may continue after that time once started. A secret can be used to create multiple sessions until it expires.
sessionobjectoptional
Session configuration to use for the client secret. Choose either a realtime session or a transcription session.

4 status codes
200Client secret created successfully.
valuestringrequired
The generated client secret value.
expires_atintegerrequired
Expiration timestamp for the client secret, in seconds since epoch.
sessionobjectrequired
The session configuration for either a realtime or transcription session.
400Invalid session configuration or model.
errorobjectrequired
404The requested model was not found or is unavailable to this caller.
errorobjectrequired
500The requested model's availability could not be determined.
errorobjectrequired

Error handling

A 400 is returned: Invalid session configuration or model. A 404 is returned: The requested model was not found or is unavailable to this caller. A 500 is returned: The requested model's availability could not be determined.