Realtime
RealtimeClient Secrets
resource openai_realtime_client_secret
openai_realtime_client_secret
resource "openai_realtime_client_secret" "example_realtime_client_secret" {
expires_after = {
anchor = "created_at"
seconds = 10
}
session = {
type = "realtime"
audio = {
input = {
format = {
rate = 24000
type = "audio/pcm"
}
noise_reduction = {
type = "near_field"
}
transcription = {
language = "language"
model = "string"
prompt = "prompt"
}
turn_detection = {
type = "server_vad"
create_response = true
idle_timeout_ms = 5000
interrupt_response = true
prefix_padding_ms = 0
silence_duration_ms = 0
threshold = 0
}
}
output = {
format = {
rate = 24000
type = "audio/pcm"
}
speed = 0.25
voice = "string"
}
}
include = ["item.input_audio_transcription.logprobs"]
instructions = "instructions"
max_output_tokens = 0
model = "string"
output_modalities = ["text"]
prompt = {
id = "id"
variables = {
foo = "string"
}
version = "version"
}
tool_choice = "none"
tools = [{
description = "description"
name = "name"
parameters = {
}
type = "function"
}]
tracing = "auto"
truncation = "auto"
}
}
RealtimeCalls
resource openai_realtime_call
openai_realtime_call
resource "openai_realtime_call" "example_realtime_call" {
sdp = "sdp"
session = {
type = "realtime"
audio = {
input = {
format = {
rate = 24000
type = "audio/pcm"
}
noise_reduction = {
type = "near_field"
}
transcription = {
language = "language"
model = "string"
prompt = "prompt"
}
turn_detection = {
type = "server_vad"
create_response = true
idle_timeout_ms = 5000
interrupt_response = true
prefix_padding_ms = 0
silence_duration_ms = 0
threshold = 0
}
}
output = {
format = {
rate = 24000
type = "audio/pcm"
}
speed = 0.25
voice = "string"
}
}
include = ["item.input_audio_transcription.logprobs"]
instructions = "instructions"
max_output_tokens = 0
model = "string"
output_modalities = ["text"]
prompt = {
id = "id"
variables = {
foo = "string"
}
version = "version"
}
tool_choice = "none"
tools = [{
description = "description"
name = "name"
parameters = {
}
type = "function"
}]
tracing = "auto"
truncation = "auto"
}
}
RealtimeSessions
resource openai_realtime_session
optional
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.
How the model chooses tools. Options are auto, none, required, or
specify a function.
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.
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.
The voice the model uses to respond. Supported built-in voices are
alloy, ash, ballad, coral, echo, sage, shimmer, verse,
marin, and cedar. You may also provide a custom voice object with an
id, for example { "id": "voice_1234" }. Voice cannot be changed during
the session once the model has responded with audio at least once.
The set of modalities the model can respond with. To disable audio, set this to [“text”].