Class RealtimeResponseCreateParams.ToolChoice
-
- All Implemented Interfaces:
public final class RealtimeResponseCreateParams.ToolChoiceHow the model chooses tools. Provide one of the string modes or force a specific function/MCP tool.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceRealtimeResponseCreateParams.ToolChoice.VisitorAn interface that defines how to map each variant of ToolChoice to a value of type T.
-
Method Summary
Modifier and Type Method Description final Optional<ToolChoiceOptions>options()Controls which (if any) tool is called by the model. final Optional<ToolChoiceFunction>function()Use this option to force the model to call a specific function. final Optional<ToolChoiceMcp>mcp()Use this option to force the model to call a specific tool on a remote MCP server. final BooleanisOptions()final BooleanisFunction()final BooleanisMcp()final ToolChoiceOptionsasOptions()Controls which (if any) tool is called by the model. final ToolChoiceFunctionasFunction()Use this option to force the model to call a specific function. final ToolChoiceMcpasMcp()Use this option to force the model to call a specific tool on a remote MCP server. final Optional<JsonValue>_json()final <T extends Any> Taccept(RealtimeResponseCreateParams.ToolChoice.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final RealtimeResponseCreateParams.ToolChoicevalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static RealtimeResponseCreateParams.ToolChoiceofOptions(ToolChoiceOptions options)Controls which (if any) tool is called by the model. final static RealtimeResponseCreateParams.ToolChoiceofFunction(ToolChoiceFunction function)Use this option to force the model to call a specific function. final static RealtimeResponseCreateParams.ToolChoiceofMcp(ToolChoiceMcp mcp)Use this option to force the model to call a specific tool on a remote MCP server. -
-
Method Detail
-
options
final Optional<ToolChoiceOptions> options()
Controls which (if any) tool is called by the model.
nonemeans the model will not call any tool and instead generates a message.automeans the model can pick between generating a message or calling one or more tools.requiredmeans the model must call one or more tools.
-
function
final Optional<ToolChoiceFunction> function()
Use this option to force the model to call a specific function.
-
mcp
final Optional<ToolChoiceMcp> mcp()
Use this option to force the model to call a specific tool on a remote MCP server.
-
isFunction
final Boolean isFunction()
-
asOptions
final ToolChoiceOptions asOptions()
Controls which (if any) tool is called by the model.
nonemeans the model will not call any tool and instead generates a message.automeans the model can pick between generating a message or calling one or more tools.requiredmeans the model must call one or more tools.
-
asFunction
final ToolChoiceFunction asFunction()
Use this option to force the model to call a specific function.
-
asMcp
final ToolChoiceMcp asMcp()
Use this option to force the model to call a specific tool on a remote MCP server.
-
accept
final <T extends Any> T accept(RealtimeResponseCreateParams.ToolChoice.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.openai.core.JsonValue; import java.util.Optional; Optional<String> result = toolChoice.accept(new ToolChoice.Visitor<Optional<String>>() { @Override public Optional<String> visitOptions(ToolChoiceOptions options) { return Optional.of(options.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final RealtimeResponseCreateParams.ToolChoice 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.
-
ofOptions
final static RealtimeResponseCreateParams.ToolChoice ofOptions(ToolChoiceOptions options)
Controls which (if any) tool is called by the model.
nonemeans the model will not call any tool and instead generates a message.automeans the model can pick between generating a message or calling one or more tools.requiredmeans the model must call one or more tools.
-
ofFunction
final static RealtimeResponseCreateParams.ToolChoice ofFunction(ToolChoiceFunction function)
Use this option to force the model to call a specific function.
-
ofMcp
final static RealtimeResponseCreateParams.ToolChoice ofMcp(ToolChoiceMcp mcp)
Use this option to force the model to call a specific tool on a remote MCP server.
-
-
-
-