Class ResponseCreateParams.ToolChoice
-
- All Implemented Interfaces:
public final class ResponseCreateParams.ToolChoiceHow the model should select which tool (or tools) to use when generating a response. See the
toolsparameter to see how to specify which tools the model can call.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceResponseCreateParams.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<BetaToolChoiceOptions>betaToolChoiceOptions()Controls which (if any) tool is called by the model. final Optional<BetaToolChoiceAllowed>betaToolChoiceAllowed()Constrains the tools available to the model to a pre-defined set. final Optional<BetaToolChoiceTypes>betaToolChoiceTypes()Indicates that the model should use a built-in tool to generate a response. final Optional<BetaToolChoiceFunction>betaToolChoiceFunction()Use this option to force the model to call a specific function. final Optional<BetaToolChoiceMcp>betaToolChoiceMcp()Use this option to force the model to call a specific tool on a remote MCP server. final Optional<BetaToolChoiceCustom>betaToolChoiceCustom()Use this option to force the model to call a specific custom tool. final Optional<JsonValue>betaSpecificProgrammaticToolCallingParam()final Optional<BetaToolChoiceApplyPatch>betaToolChoiceApplyPatch()Forces the model to call the apply_patch tool when executing a tool call. final Optional<BetaToolChoiceShell>betaToolChoiceShell()Forces the model to call the shell tool when a tool call is required. final BooleanisBetaToolChoiceOptions()final BooleanisBetaToolChoiceAllowed()final BooleanisBetaToolChoiceTypes()final BooleanisBetaToolChoiceFunction()final BooleanisBetaToolChoiceMcp()final BooleanisBetaToolChoiceCustom()final BooleanisBetaSpecificProgrammaticToolCallingParam()final BooleanisBetaToolChoiceApplyPatch()final BooleanisBetaToolChoiceShell()final BetaToolChoiceOptionsasBetaToolChoiceOptions()Controls which (if any) tool is called by the model. final BetaToolChoiceAllowedasBetaToolChoiceAllowed()Constrains the tools available to the model to a pre-defined set. final BetaToolChoiceTypesasBetaToolChoiceTypes()Indicates that the model should use a built-in tool to generate a response. final BetaToolChoiceFunctionasBetaToolChoiceFunction()Use this option to force the model to call a specific function. final BetaToolChoiceMcpasBetaToolChoiceMcp()Use this option to force the model to call a specific tool on a remote MCP server. final BetaToolChoiceCustomasBetaToolChoiceCustom()Use this option to force the model to call a specific custom tool. final JsonValueasBetaSpecificProgrammaticToolCallingParam()final BetaToolChoiceApplyPatchasBetaToolChoiceApplyPatch()Forces the model to call the apply_patch tool when executing a tool call. final BetaToolChoiceShellasBetaToolChoiceShell()Forces the model to call the shell tool when a tool call is required. final Optional<JsonValue>_json()final <T extends Any> Taccept(ResponseCreateParams.ToolChoice.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final ResponseCreateParams.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 ResponseCreateParams.ToolChoiceofBetaToolChoiceOptions(BetaToolChoiceOptions betaToolChoiceOptions)Controls which (if any) tool is called by the model. final static ResponseCreateParams.ToolChoiceofBetaToolChoiceAllowed(BetaToolChoiceAllowed betaToolChoiceAllowed)Constrains the tools available to the model to a pre-defined set. final static ResponseCreateParams.ToolChoiceofBetaToolChoiceTypes(BetaToolChoiceTypes betaToolChoiceTypes)Indicates that the model should use a built-in tool to generate a response. final static ResponseCreateParams.ToolChoiceofBetaToolChoiceFunction(BetaToolChoiceFunction betaToolChoiceFunction)Use this option to force the model to call a specific function. final static ResponseCreateParams.ToolChoiceofBetaToolChoiceMcp(BetaToolChoiceMcp betaToolChoiceMcp)Use this option to force the model to call a specific tool on a remote MCP server. final static ResponseCreateParams.ToolChoiceofBetaToolChoiceCustom(BetaToolChoiceCustom betaToolChoiceCustom)Use this option to force the model to call a specific custom tool. final static ResponseCreateParams.ToolChoiceofBetaSpecificProgrammaticToolCallingParam()final static ResponseCreateParams.ToolChoiceofBetaToolChoiceApplyPatch(BetaToolChoiceApplyPatch betaToolChoiceApplyPatch)Forces the model to call the apply_patch tool when executing a tool call. final static ResponseCreateParams.ToolChoiceofBetaToolChoiceShell(BetaToolChoiceShell betaToolChoiceShell)Forces the model to call the shell tool when a tool call is required. -
-
Method Detail
-
betaToolChoiceOptions
final Optional<BetaToolChoiceOptions> betaToolChoiceOptions()
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.
-
betaToolChoiceAllowed
final Optional<BetaToolChoiceAllowed> betaToolChoiceAllowed()
Constrains the tools available to the model to a pre-defined set.
-
betaToolChoiceTypes
final Optional<BetaToolChoiceTypes> betaToolChoiceTypes()
Indicates that the model should use a built-in tool to generate a response. Learn more about built-in tools.
-
betaToolChoiceFunction
final Optional<BetaToolChoiceFunction> betaToolChoiceFunction()
Use this option to force the model to call a specific function.
-
betaToolChoiceMcp
final Optional<BetaToolChoiceMcp> betaToolChoiceMcp()
Use this option to force the model to call a specific tool on a remote MCP server.
-
betaToolChoiceCustom
final Optional<BetaToolChoiceCustom> betaToolChoiceCustom()
Use this option to force the model to call a specific custom tool.
-
betaSpecificProgrammaticToolCallingParam
final Optional<JsonValue> betaSpecificProgrammaticToolCallingParam()
-
betaToolChoiceApplyPatch
final Optional<BetaToolChoiceApplyPatch> betaToolChoiceApplyPatch()
Forces the model to call the apply_patch tool when executing a tool call.
-
betaToolChoiceShell
final Optional<BetaToolChoiceShell> betaToolChoiceShell()
Forces the model to call the shell tool when a tool call is required.
-
isBetaToolChoiceOptions
final Boolean isBetaToolChoiceOptions()
-
isBetaToolChoiceAllowed
final Boolean isBetaToolChoiceAllowed()
-
isBetaToolChoiceTypes
final Boolean isBetaToolChoiceTypes()
-
isBetaToolChoiceFunction
final Boolean isBetaToolChoiceFunction()
-
isBetaToolChoiceMcp
final Boolean isBetaToolChoiceMcp()
-
isBetaToolChoiceCustom
final Boolean isBetaToolChoiceCustom()
-
isBetaSpecificProgrammaticToolCallingParam
final Boolean isBetaSpecificProgrammaticToolCallingParam()
-
isBetaToolChoiceApplyPatch
final Boolean isBetaToolChoiceApplyPatch()
-
isBetaToolChoiceShell
final Boolean isBetaToolChoiceShell()
-
asBetaToolChoiceOptions
final BetaToolChoiceOptions asBetaToolChoiceOptions()
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.
-
asBetaToolChoiceAllowed
final BetaToolChoiceAllowed asBetaToolChoiceAllowed()
Constrains the tools available to the model to a pre-defined set.
-
asBetaToolChoiceTypes
final BetaToolChoiceTypes asBetaToolChoiceTypes()
Indicates that the model should use a built-in tool to generate a response. Learn more about built-in tools.
-
asBetaToolChoiceFunction
final BetaToolChoiceFunction asBetaToolChoiceFunction()
Use this option to force the model to call a specific function.
-
asBetaToolChoiceMcp
final BetaToolChoiceMcp asBetaToolChoiceMcp()
Use this option to force the model to call a specific tool on a remote MCP server.
-
asBetaToolChoiceCustom
final BetaToolChoiceCustom asBetaToolChoiceCustom()
Use this option to force the model to call a specific custom tool.
-
asBetaSpecificProgrammaticToolCallingParam
final JsonValue asBetaSpecificProgrammaticToolCallingParam()
-
asBetaToolChoiceApplyPatch
final BetaToolChoiceApplyPatch asBetaToolChoiceApplyPatch()
Forces the model to call the apply_patch tool when executing a tool call.
-
asBetaToolChoiceShell
final BetaToolChoiceShell asBetaToolChoiceShell()
Forces the model to call the shell tool when a tool call is required.
-
accept
final <T extends Any> T accept(ResponseCreateParams.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> visitBetaToolChoiceOptions(BetaToolChoiceOptions betaToolChoiceOptions) { return Optional.of(betaToolChoiceOptions.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final ResponseCreateParams.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.
-
ofBetaToolChoiceOptions
final static ResponseCreateParams.ToolChoice ofBetaToolChoiceOptions(BetaToolChoiceOptions betaToolChoiceOptions)
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.
-
ofBetaToolChoiceAllowed
final static ResponseCreateParams.ToolChoice ofBetaToolChoiceAllowed(BetaToolChoiceAllowed betaToolChoiceAllowed)
Constrains the tools available to the model to a pre-defined set.
-
ofBetaToolChoiceTypes
final static ResponseCreateParams.ToolChoice ofBetaToolChoiceTypes(BetaToolChoiceTypes betaToolChoiceTypes)
Indicates that the model should use a built-in tool to generate a response. Learn more about built-in tools.
-
ofBetaToolChoiceFunction
final static ResponseCreateParams.ToolChoice ofBetaToolChoiceFunction(BetaToolChoiceFunction betaToolChoiceFunction)
Use this option to force the model to call a specific function.
-
ofBetaToolChoiceMcp
final static ResponseCreateParams.ToolChoice ofBetaToolChoiceMcp(BetaToolChoiceMcp betaToolChoiceMcp)
Use this option to force the model to call a specific tool on a remote MCP server.
-
ofBetaToolChoiceCustom
final static ResponseCreateParams.ToolChoice ofBetaToolChoiceCustom(BetaToolChoiceCustom betaToolChoiceCustom)
Use this option to force the model to call a specific custom tool.
-
ofBetaSpecificProgrammaticToolCallingParam
final static ResponseCreateParams.ToolChoice ofBetaSpecificProgrammaticToolCallingParam()
-
ofBetaToolChoiceApplyPatch
final static ResponseCreateParams.ToolChoice ofBetaToolChoiceApplyPatch(BetaToolChoiceApplyPatch betaToolChoiceApplyPatch)
Forces the model to call the apply_patch tool when executing a tool call.
-
ofBetaToolChoiceShell
final static ResponseCreateParams.ToolChoice ofBetaToolChoiceShell(BetaToolChoiceShell betaToolChoiceShell)
Forces the model to call the shell tool when a tool call is required.
-
-
-
-