One of the following:
Literal["none", "auto", "required"]
One of the following:
"none"
"auto"
"required"
class BetaToolChoiceAllowed:

Constrains the tools available to the model to a pre-defined set.

mode: Literal["auto", "required"]

Constrains the tools available to the model to a pre-defined set.

auto allows the model to pick from among the allowed tools and generate a message.

required requires the model to call one or more of the allowed tools.

One of the following:
"auto"
"required"
tools: List[Dict[str, object]]

A list of tool definitions that the model should be allowed to call.

For the Responses API, the list of tool definitions might look like:

[
  { "type": "function", "name": "get_weather" },
  { "type": "mcp", "server_label": "deepwiki" },
  { "type": "image_generation" }
]
type: Literal["allowed_tools"]

Allowed tool configuration type. Always allowed_tools.

class BetaToolChoiceTypes:

Indicates that the model should use a built-in tool to generate a response. Learn more about built-in tools.

type: Literal["file_search", "web_search_preview", "computer", 5 more]

The type of hosted tool the model should to use. Learn more about built-in tools.

Allowed values are:

  • file_search
  • web_search_preview
  • computer
  • computer_use_preview
  • computer_use
  • code_interpreter
  • image_generation
One of the following:
"file_search"
"web_search_preview"
"computer"
"computer_use_preview"
"computer_use"
"web_search_preview_2025_03_11"
"image_generation"
"code_interpreter"
class BetaToolChoiceFunction:

Use this option to force the model to call a specific function.

name: str

The name of the function to call.

type: Literal["function"]

For function calling, the type is always function.

class BetaToolChoiceMcp:

Use this option to force the model to call a specific tool on a remote MCP server.

server_label: str

The label of the MCP server to use.

type: Literal["mcp"]

For MCP tools, the type is always mcp.

name: Optional[str]

The name of the tool to call on the server.

class BetaToolChoiceCustom:

Use this option to force the model to call a specific custom tool.

name: str

The name of the custom tool to call.

type: Literal["custom"]

For custom tool calling, the type is always custom.

class ToolChoiceBetaSpecificProgrammaticToolCallingParam:
type: Literal["programmatic_tool_calling"]

The tool to call. Always programmatic_tool_calling.

class BetaToolChoiceApplyPatch:

Forces the model to call the apply_patch tool when executing a tool call.

type: Literal["apply_patch"]

The tool to call. Always apply_patch.

class BetaToolChoiceShell:

Forces the model to call the shell tool when a tool call is required.

type: Literal["shell"]

The tool to call. Always shell.