Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation
Theme

Create translation client secret

client.realtime.translations.clientSecrets.create(body, options?): RealtimeTranslationClientSecretCreateResponse { expires_at, session, value }
POST
/realtime/translations/client_secrets

Create 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.

Parameters
body: ClientSecretCreateParams { session, expires_after }
session: RealtimeTranslationSessionCreateRequest { model, audio }

Realtime translation session configuration. Translation sessions stream source audio in and translated audio plus transcript deltas out continuously.

expires_after?: ExpiresAfter

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.

Returns
RealtimeTranslationClientSecretCreateResponse { expires_at, session, value }

Response from creating a translation session and client secret for the Realtime API.

expires_at: number

Expiration timestamp for the client secret, in seconds since epoch.

formatunixtime
session: RealtimeTranslationSession { id, audio, expires_at, 2 more }

A Realtime translation session. Translation sessions continuously translate input audio into the configured output language.

value: string

The generated client secret value.

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"
      }
    }
  }
}