Class ResponseCreateParams.ToolChoice
-
- All Implemented Interfaces:
public final class ResponseCreateParams.ToolChoice
How the model should select which tool (or tools) to use when generating a response. See the
tools
parameter to see how to specify which tools the model can call.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
ResponseCreateParams.ToolChoice.Visitor
An 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<ToolChoiceAllowed>
allowed()
Constrains the tools available to the model to a pre-defined set. final Optional<ToolChoiceTypes>
types()
Indicates that the model should use a built-in tool to generate a response. 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 Optional<ToolChoiceCustom>
custom()
Use this option to force the model to call a specific custom tool. final Boolean
isOptions()
final Boolean
isAllowed()
final Boolean
isTypes()
final Boolean
isFunction()
final Boolean
isMcp()
final Boolean
isCustom()
final ToolChoiceOptions
asOptions()
Controls which (if any) tool is called by the model. final ToolChoiceAllowed
asAllowed()
Constrains the tools available to the model to a pre-defined set. final ToolChoiceTypes
asTypes()
Indicates that the model should use a built-in tool to generate a response. final ToolChoiceFunction
asFunction()
Use this option to force the model to call a specific function. final ToolChoiceMcp
asMcp()
Use this option to force the model to call a specific tool on a remote MCP server. final ToolChoiceCustom
asCustom()
Use this option to force the model to call a specific custom tool. final Optional<JsonValue>
_json()
final <T extends Any> T
accept(ResponseCreateParams.ToolChoice.Visitor<T> visitor)
final ResponseCreateParams.ToolChoice
validate()
final Boolean
isValid()
Boolean
equals(Object other)
Integer
hashCode()
String
toString()
final static ResponseCreateParams.ToolChoice
ofOptions(ToolChoiceOptions options)
Controls which (if any) tool is called by the model. final static ResponseCreateParams.ToolChoice
ofAllowed(ToolChoiceAllowed allowed)
Constrains the tools available to the model to a pre-defined set. final static ResponseCreateParams.ToolChoice
ofTypes(ToolChoiceTypes types)
Indicates that the model should use a built-in tool to generate a response. final static ResponseCreateParams.ToolChoice
ofFunction(ToolChoiceFunction function)
Use this option to force the model to call a specific function. final static ResponseCreateParams.ToolChoice
ofMcp(ToolChoiceMcp mcp)
Use this option to force the model to call a specific tool on a remote MCP server. final static ResponseCreateParams.ToolChoice
ofCustom(ToolChoiceCustom custom)
Use this option to force the model to call a specific custom tool. -
-
Method Detail
-
options
final Optional<ToolChoiceOptions> options()
Controls which (if any) tool is called by the model.
none
means the model will not call any tool and instead generates a message.auto
means the model can pick between generating a message or calling one or more tools.required
means the model must call one or more tools.
-
allowed
final Optional<ToolChoiceAllowed> allowed()
Constrains the tools available to the model to a pre-defined set.
-
types
final Optional<ToolChoiceTypes> types()
Indicates that the model should use a built-in tool to generate a response. Learn more about built-in 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.
-
custom
final Optional<ToolChoiceCustom> custom()
Use this option to force the model to call a specific custom tool.
-
isFunction
final Boolean isFunction()
-
asOptions
final ToolChoiceOptions asOptions()
Controls which (if any) tool is called by the model.
none
means the model will not call any tool and instead generates a message.auto
means the model can pick between generating a message or calling one or more tools.required
means the model must call one or more tools.
-
asAllowed
final ToolChoiceAllowed asAllowed()
Constrains the tools available to the model to a pre-defined set.
-
asTypes
final ToolChoiceTypes asTypes()
Indicates that the model should use a built-in tool to generate a response. Learn more about built-in 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.
-
asCustom
final ToolChoiceCustom asCustom()
Use this option to force the model to call a specific custom tool.
-
accept
final <T extends Any> T accept(ResponseCreateParams.ToolChoice.Visitor<T> visitor)
-
validate
final ResponseCreateParams.ToolChoice validate()
-
ofOptions
final static ResponseCreateParams.ToolChoice ofOptions(ToolChoiceOptions options)
Controls which (if any) tool is called by the model.
none
means the model will not call any tool and instead generates a message.auto
means the model can pick between generating a message or calling one or more tools.required
means the model must call one or more tools.
-
ofAllowed
final static ResponseCreateParams.ToolChoice ofAllowed(ToolChoiceAllowed allowed)
Constrains the tools available to the model to a pre-defined set.
-
ofTypes
final static ResponseCreateParams.ToolChoice ofTypes(ToolChoiceTypes types)
Indicates that the model should use a built-in tool to generate a response. Learn more about built-in tools.
-
ofFunction
final static ResponseCreateParams.ToolChoice ofFunction(ToolChoiceFunction function)
Use this option to force the model to call a specific function.
-
ofMcp
final static ResponseCreateParams.ToolChoice ofMcp(ToolChoiceMcp mcp)
Use this option to force the model to call a specific tool on a remote MCP server.
-
ofCustom
final static ResponseCreateParams.ToolChoice ofCustom(ToolChoiceCustom custom)
Use this option to force the model to call a specific custom tool.
-
-
-
-