---
title: "Create session"
method: POST
path: "/realtime/sessions"
tags: ["Realtime"]
---

# Create session

`POST /realtime/sessions`

Create an ephemeral API token for use in client-side applications with the
Realtime API. Can be configured with the same session parameters as the
`session.update` client event.

It responds with a session object, plus a `client_secret` key which contains
a usable ephemeral API token that can be used to authenticate browser clients
for the Realtime API.

Returns the created Realtime session object, plus an ephemeral key.

## Request body

- RealtimeSessionCreateRequest — A new Realtime session configuration, with an ephemeral key. Default TTL for keys is one minute.
  - `client_secret` object, required — Ephemeral key returned by the API.
    - `value` string, required — Ephemeral key usable in client environments to authenticate connections to the Realtime API. Use this in client-side environments rather than a standard API token, which should only be used server-side.
    - `expires_at` integer, required — Timestamp for when the token expires. Currently, all tokens expire after one minute.
  - `modalities` string[] — The set of modalities the model can respond with. To disable audio, set this to ["text"].
  - `instructions` string — The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior. Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.
  - `voice` union — A built-in voice name or a custom voice reference.
    - union
      - string
      - 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse' | 'marin' | 'cedar'
    - object — Custom voice reference.
      - `id` string, required — The custom voice ID, e.g. `voice_1234`.
  - `input_audio_format` string — The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
  - `output_audio_format` string — The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
  - `input_audio_transcription` object — Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously and should be treated as rough guidance rather than the representation understood by the model.
    - `model` string — The model to use for transcription.
  - `speed` number — The speed of the model's spoken response. 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.
  - `tracing` union — Configuration options for tracing. Set to null to disable tracing. Once tracing is enabled for a session, the configuration cannot be modified. `auto` will create a trace for the session with default values for the workflow name, group id, and metadata.
    - 'auto' — Default tracing mode for the session.
    - object — Granular configuration for tracing.
      - `workflow_name` string — The name of the workflow to attach to this trace. This is used to name the trace in the traces dashboard.
      - `group_id` string — The group id to attach to this trace to enable filtering and grouping in the traces dashboard.
      - `metadata` object — The arbitrary metadata to attach to this trace to enable filtering in the traces dashboard.
  - `turn_detection` object — Configuration for turn detection. Can be set to `null` to turn off. Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.
    - `type` string — Type of turn detection, only `server_vad` is currently supported.
    - `threshold` number — Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A higher threshold will require louder audio to activate the model, and thus might perform better in noisy environments.
    - `prefix_padding_ms` integer — Amount of audio to include before the VAD detected speech (in milliseconds). Defaults to 300ms.
    - `silence_duration_ms` integer — Duration of silence to detect speech stop (in milliseconds). Defaults to 500ms. With shorter values the model will respond more quickly, but may jump in on short pauses from the user.
  - `tools` object[] — Tools (functions) available to the model.
    - `type` 'function' — The type of the tool, i.e. `function`.
    - `name` string — The name of the function.
    - `description` string — The description of the function, including guidance on when and how to call it, and guidance about what to tell the user when calling (if anything).
    - `parameters` object — Parameters of the function in JSON Schema.
  - `tool_choice` string — How the model chooses tools. Options are `auto`, `none`, `required`, or specify a function.
  - `temperature` number — Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
  - `max_response_output_tokens` union — Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or `inf` for the maximum available tokens for a given model. Defaults to `inf`.
    - integer
    - 'inf'
  - `truncation` union — When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs. Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost. Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate. Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.
    - 'auto' | 'disabled' — The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit.
    - object — Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.
      - `type` 'retention_ratio', required — Use retention ratio truncation.
      - `retention_ratio` number, required — Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.
      - `token_limits` object — Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.
        - `post_instructions` integer — Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.
  - `prompt` Prompt, nullable — Reference to a prompt template and its variables. [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
    - `id` string, required — The unique identifier of the prompt template to use.
    - `version` string, nullable — Optional version of the prompt template.
    - `variables` ResponsePromptVariables, nullable — Optional map of values to substitute in for variables in your prompt. The substitution values can either be strings, or other Response input types like images or files.

## Response `200`

Session created successfully.

- RealtimeSessionCreateResponse — A Realtime session configuration object.
  - `id` string — Unique identifier for the session that looks like `sess_1234567890abcdef`.
  - `object` string — The object type. Always `realtime.session`.
  - `expires_at` integer — Expiration timestamp for the session, in seconds since epoch.
  - `include` string[] — Additional fields to include in server outputs. - `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.
  - `model` string — The Realtime model used for this session.
  - `output_modalities` string[] — The set of modalities the model can respond with. To disable audio, set this to ["text"].
  - `instructions` string — The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior. Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.
  - `audio` object — Configuration for input and output audio for the session.
    - `input` object
      - `format` union
        - object — The PCM audio format. Only a 24kHz sample rate is supported.
          - `type` 'audio/pcm' — The audio format. Always `audio/pcm`.
          - `rate` 24000 — The sample rate of the audio. Always `24000`.
        - object — The G.711 μ-law format.
          - `type` 'audio/pcmu' — The audio format. Always `audio/pcmu`.
        - object — The G.711 A-law format.
          - `type` 'audio/pcma' — The audio format. Always `audio/pcma`.
      - `transcription` AudioTranscription
        - `model` union — The model to use for transcription. Current options are `whisper-1`, `gpt-transcribe`, `gpt-live-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
          - string
          - 'whisper-1' | 'gpt-transcribe' | 'gpt-live-transcribe' | 'gpt-4o-mini-transcribe' | 'gpt-4o-mini-transcribe-2025-12-15' | 'gpt-4o-transcribe' | 'gpt-4o-transcribe-diarize' | 'gpt-realtime-whisper'
        - `language` string — The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format will improve accuracy and latency.
        - `languages` string[] — Possible languages of the input audio, in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. Supported by `gpt-transcribe` and `gpt-live-transcribe`.
        - `keywords` string[] — Words or phrases to guide transcription of the input audio. Supported by `gpt-transcribe` and `gpt-live-transcribe`.
        - `prompt` string — An optional text to guide the model's style or continue a previous audio segment. For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting). For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology". Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.
        - `delay` 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' — Controls how long the model waits before emitting transcription text. Higher values can improve transcription accuracy at the cost of latency. Only supported with `gpt-realtime-whisper` in GA Realtime sessions.
      - `noise_reduction` object — Configuration for input audio noise reduction.
        - `type` 'near_field' | 'far_field' — Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.
      - `turn_detection` object — Configuration for turn detection.
        - `type` string — Type of turn detection, only `server_vad` is currently supported.
        - `threshold` number
        - `prefix_padding_ms` integer
        - `silence_duration_ms` integer
    - `output` object
      - `format` union
        - object — The PCM audio format. Only a 24kHz sample rate is supported.
          - `type` 'audio/pcm' — The audio format. Always `audio/pcm`.
          - `rate` 24000 — The sample rate of the audio. Always `24000`.
        - object — The G.711 μ-law format.
          - `type` 'audio/pcmu' — The audio format. Always `audio/pcmu`.
        - object — The G.711 A-law format.
          - `type` 'audio/pcma' — The audio format. Always `audio/pcma`.
      - `voice` union
        - string
        - 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse' | 'marin' | 'cedar'
      - `speed` number
  - `tracing` union — Configuration options for tracing. Set to null to disable tracing. Once tracing is enabled for a session, the configuration cannot be modified. `auto` will create a trace for the session with default values for the workflow name, group id, and metadata.
    - 'auto' — Default tracing mode for the session.
    - object — Granular configuration for tracing.
      - `workflow_name` string — The name of the workflow to attach to this trace. This is used to name the trace in the traces dashboard.
      - `group_id` string — The group id to attach to this trace to enable filtering and grouping in the traces dashboard.
      - `metadata` object — The arbitrary metadata to attach to this trace to enable filtering in the traces dashboard.
  - `turn_detection` object — Configuration for turn detection. Can be set to `null` to turn off. Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.
    - `type` string — Type of turn detection, only `server_vad` is currently supported.
    - `threshold` number — Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A higher threshold will require louder audio to activate the model, and thus might perform better in noisy environments.
    - `prefix_padding_ms` integer — Amount of audio to include before the VAD detected speech (in milliseconds). Defaults to 300ms.
    - `silence_duration_ms` integer — Duration of silence to detect speech stop (in milliseconds). Defaults to 500ms. With shorter values the model will respond more quickly, but may jump in on short pauses from the user.
  - `tools` RealtimeFunctionTool[] — Tools (functions) available to the model.
    - `type` 'function' — The type of the tool, i.e. `function`.
    - `name` string — The name of the function.
    - `description` string — The description of the function, including guidance on when and how to call it, and guidance about what to tell the user when calling (if anything).
    - `parameters` object — Parameters of the function in JSON Schema.
  - `tool_choice` string — How the model chooses tools. Options are `auto`, `none`, `required`, or specify a function.
  - `max_output_tokens` union — Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or `inf` for the maximum available tokens for a given model. Defaults to `inf`.
    - integer
    - 'inf'

---

[API](https://skmtc.net/openai/apis/openai-api.md) · [All operations](https://skmtc.net/openai/apis/openai-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/openai/openai-api/versions/dcd35773a322/schema)
