Create translation client secret
client.realtime.translations.clientSecrets.create(ClientSecretCreateParams { session, expires_after } body , RequestOptionsoptions ?): RealtimeTranslationClientSecretCreateResponse { expires_at, session, value }
POST
/realtime/translations/client_secretsCreate a Realtime translation client secret with an associated translation 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 Translation API without leaking your main API key. You can configure a custom TTL for each client secret.
Returns the created client secret and the effective translation session object.
The client secret is a string that looks like ek_1234.
Create translation client secret
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});
const realtimeTranslationClientSecretCreateResponse =
await client.realtime.translations.clientSecrets.create({ session: { model: 'model' } });
console.log(realtimeTranslationClientSecretCreateResponse.expires_at);Response example
{
"value": "ek_68af296e8e408191a1120ab6383263c2",
"expires_at": 1756310470,
"session": {
"id": "sess_C9CiUVUzUzYIssh3ELY1d",
"type": "translation",
"expires_at": 1756310470,
"model": "gpt-realtime-translate",
"audio": {
"input": {
"transcription": {
"model": "gpt-realtime-whisper"
},
"noise_reduction": null
},
"output": {
"language": "es"
}
}
}
}
Returns Examples
Response example
{
"value": "ek_68af296e8e408191a1120ab6383263c2",
"expires_at": 1756310470,
"session": {
"id": "sess_C9CiUVUzUzYIssh3ELY1d",
"type": "translation",
"expires_at": 1756310470,
"model": "gpt-realtime-translate",
"audio": {
"input": {
"transcription": {
"model": "gpt-realtime-whisper"
},
"noise_reduction": null
},
"output": {
"language": "es"
}
}
}
}