Class RealtimeSessionCreateResponse
-
- All Implemented Interfaces:
public final class RealtimeSessionCreateResponseA Realtime session configuration object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classRealtimeSessionCreateResponse.BuilderA builder for RealtimeSessionCreateResponse.
public final classRealtimeSessionCreateResponse.AudioConfiguration for input and output audio.
public final classRealtimeSessionCreateResponse.Includepublic final classRealtimeSessionCreateResponse.MaxOutputTokensMaximum 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
inffor the maximum available tokens for a given model. Defaults toinf.public final classRealtimeSessionCreateResponse.ModelThe Realtime model used for this session.
public final classRealtimeSessionCreateResponse.OutputModalitypublic final classRealtimeSessionCreateResponse.ToolChoiceHow the model chooses tools. Provide one of the string modes or force a specific function/MCP tool.
public final classRealtimeSessionCreateResponse.ToolGive the model access to additional tools via remote Model Context Protocol (MCP) servers. Learn more about MCP.
public final classRealtimeSessionCreateResponse.TracingRealtime API can write session traces to the Traces Dashboard. Set to null to disable tracing. Once tracing is enabled for a session, the configuration cannot be modified.
autowill create a trace for the session with default values for the workflow name, group id, and metadata.
-
Method Summary
Modifier and Type Method Description final Stringid()Unique identifier for the session that looks like sess_1234567890abcdef.final JsonValue_object_()The object type. final JsonValue_type()The type of session to create. final Optional<RealtimeSessionCreateResponse.Audio>audio()Configuration for input and output audio. final Optional<Long>expiresAt()Expiration timestamp for the session, in seconds since epoch. final Optional<List<RealtimeSessionCreateResponse.Include>>include()Additional fields to include in server outputs. final Optional<String>instructions()The default system instructions (i.e. final Optional<RealtimeSessionCreateResponse.MaxOutputTokens>maxOutputTokens()Maximum number of output tokens for a single assistant response, inclusive of tool calls. final Optional<RealtimeSessionCreateResponse.Model>model()The Realtime model used for this session. final Optional<List<RealtimeSessionCreateResponse.OutputModality>>outputModalities()The set of modalities the model can respond with. final Optional<ResponsePrompt>prompt()Reference to a prompt template and its variables. final Optional<RealtimeReasoning>reasoning()Configuration for reasoning-capable Realtime models such as gpt-realtime-2.final Optional<RealtimeSessionCreateResponse.ToolChoice>toolChoice()How the model chooses tools. final Optional<List<RealtimeSessionCreateResponse.Tool>>tools()Tools available to the model. final Optional<RealtimeSessionCreateResponse.Tracing>tracing()Realtime API can write session traces to the Traces Dashboard. final Optional<RealtimeTruncation>truncation()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. final JsonField<String>_id()Returns the raw JSON value of id. final JsonField<RealtimeSessionCreateResponse.Audio>_audio()Returns the raw JSON value of audio. final JsonField<Long>_expiresAt()Returns the raw JSON value of expiresAt. final JsonField<List<RealtimeSessionCreateResponse.Include>>_include()Returns the raw JSON value of include. final JsonField<String>_instructions()Returns the raw JSON value of instructions. final JsonField<RealtimeSessionCreateResponse.MaxOutputTokens>_maxOutputTokens()Returns the raw JSON value of maxOutputTokens. final JsonField<RealtimeSessionCreateResponse.Model>_model()Returns the raw JSON value of model. final JsonField<List<RealtimeSessionCreateResponse.OutputModality>>_outputModalities()Returns the raw JSON value of outputModalities. final JsonField<ResponsePrompt>_prompt()Returns the raw JSON value of prompt. final JsonField<RealtimeReasoning>_reasoning()Returns the raw JSON value of reasoning. final JsonField<RealtimeSessionCreateResponse.ToolChoice>_toolChoice()Returns the raw JSON value of toolChoice. final JsonField<List<RealtimeSessionCreateResponse.Tool>>_tools()Returns the raw JSON value of tools. final JsonField<RealtimeSessionCreateResponse.Tracing>_tracing()Returns the raw JSON value of tracing. final JsonField<RealtimeTruncation>_truncation()Returns the raw JSON value of truncation. final Map<String, JsonValue>_additionalProperties()final RealtimeSessionCreateResponse.BuildertoBuilder()final RealtimeSessionCreateResponsevalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static RealtimeSessionCreateResponse.Builderbuilder()Returns a mutable builder for constructing an instance of RealtimeSessionCreateResponse. -
-
Method Detail
-
_object_
final JsonValue _object_()
The object type. Always
realtime.session.Expected to always return the following:
JsonValue.from("realtime.session")However, this method can be useful for debugging and logging (e.g. if the server responded with an unexpected value).
-
_type
final JsonValue _type()
The type of session to create. Always
realtimefor the Realtime API.Expected to always return the following:
JsonValue.from("realtime")However, this method can be useful for debugging and logging (e.g. if the server responded with an unexpected value).
-
audio
final Optional<RealtimeSessionCreateResponse.Audio> audio()
Configuration for input and output audio.
-
expiresAt
final Optional<Long> expiresAt()
Expiration timestamp for the session, in seconds since epoch.
-
include
final Optional<List<RealtimeSessionCreateResponse.Include>> include()
Additional fields to include in server outputs.
item.input_audio_transcription.logprobs: Include logprobs for input audio transcription.
-
instructions
final Optional<String> instructions()
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.createdevent at the start of the session.
-
maxOutputTokens
final Optional<RealtimeSessionCreateResponse.MaxOutputTokens> maxOutputTokens()
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
inffor the maximum available tokens for a given model. Defaults toinf.
-
model
final Optional<RealtimeSessionCreateResponse.Model> model()
The Realtime model used for this session.
-
outputModalities
final Optional<List<RealtimeSessionCreateResponse.OutputModality>> outputModalities()
The set of modalities the model can respond with. It defaults to
["audio"], indicating that the model will respond with audio plus a transcript.["text"]can be used to make the model respond with text only. It is not possible to request bothtextandaudioat the same time.
-
prompt
final Optional<ResponsePrompt> prompt()
Reference to a prompt template and its variables. Learn more.
-
reasoning
final Optional<RealtimeReasoning> reasoning()
Configuration for reasoning-capable Realtime models such as
gpt-realtime-2.
-
toolChoice
final Optional<RealtimeSessionCreateResponse.ToolChoice> toolChoice()
How the model chooses tools. Provide one of the string modes or force a specific function/MCP tool.
-
tools
final Optional<List<RealtimeSessionCreateResponse.Tool>> tools()
Tools available to the model.
-
tracing
final Optional<RealtimeSessionCreateResponse.Tracing> tracing()
Realtime API can write session traces to the Traces Dashboard. Set to null to disable tracing. Once tracing is enabled for a session, the configuration cannot be modified.
autowill create a trace for the session with default values for the workflow name, group id, and metadata.
-
truncation
final Optional<RealtimeTruncation> truncation()
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.
-
_id
final JsonField<String> _id()
Returns the raw JSON value of id.
Unlike id, this method doesn't throw if the JSON field has an unexpected type.
-
_audio
final JsonField<RealtimeSessionCreateResponse.Audio> _audio()
Returns the raw JSON value of audio.
Unlike audio, this method doesn't throw if the JSON field has an unexpected type.
-
_expiresAt
final JsonField<Long> _expiresAt()
Returns the raw JSON value of expiresAt.
Unlike expiresAt, this method doesn't throw if the JSON field has an unexpected type.
-
_include
final JsonField<List<RealtimeSessionCreateResponse.Include>> _include()
Returns the raw JSON value of include.
Unlike include, this method doesn't throw if the JSON field has an unexpected type.
-
_instructions
final JsonField<String> _instructions()
Returns the raw JSON value of instructions.
Unlike instructions, this method doesn't throw if the JSON field has an unexpected type.
-
_maxOutputTokens
final JsonField<RealtimeSessionCreateResponse.MaxOutputTokens> _maxOutputTokens()
Returns the raw JSON value of maxOutputTokens.
Unlike maxOutputTokens, this method doesn't throw if the JSON field has an unexpected type.
-
_model
final JsonField<RealtimeSessionCreateResponse.Model> _model()
Returns the raw JSON value of model.
Unlike model, this method doesn't throw if the JSON field has an unexpected type.
-
_outputModalities
final JsonField<List<RealtimeSessionCreateResponse.OutputModality>> _outputModalities()
Returns the raw JSON value of outputModalities.
Unlike outputModalities, this method doesn't throw if the JSON field has an unexpected type.
-
_prompt
final JsonField<ResponsePrompt> _prompt()
Returns the raw JSON value of prompt.
Unlike prompt, this method doesn't throw if the JSON field has an unexpected type.
-
_reasoning
final JsonField<RealtimeReasoning> _reasoning()
Returns the raw JSON value of reasoning.
Unlike reasoning, this method doesn't throw if the JSON field has an unexpected type.
-
_toolChoice
final JsonField<RealtimeSessionCreateResponse.ToolChoice> _toolChoice()
Returns the raw JSON value of toolChoice.
Unlike toolChoice, this method doesn't throw if the JSON field has an unexpected type.
-
_tools
final JsonField<List<RealtimeSessionCreateResponse.Tool>> _tools()
Returns the raw JSON value of tools.
Unlike tools, this method doesn't throw if the JSON field has an unexpected type.
-
_tracing
final JsonField<RealtimeSessionCreateResponse.Tracing> _tracing()
Returns the raw JSON value of tracing.
Unlike tracing, this method doesn't throw if the JSON field has an unexpected type.
-
_truncation
final JsonField<RealtimeTruncation> _truncation()
Returns the raw JSON value of truncation.
Unlike truncation, this method doesn't throw if the JSON field has an unexpected type.
-
_additionalProperties
final Map<String, JsonValue> _additionalProperties()
-
toBuilder
final RealtimeSessionCreateResponse.Builder toBuilder()
-
validate
final RealtimeSessionCreateResponse validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
builder
final static RealtimeSessionCreateResponse.Builder builder()
Returns a mutable builder for constructing an instance of RealtimeSessionCreateResponse.
The following fields are required:
.id()
-
-
-
-