Class ToolConfig (1.119.0)

ToolConfig(
 function_calling_config: vertexai.generative_models._generative_models.ToolConfig.FunctionCallingConfig,
)

Config shared for all tools provided in the request.

Usage: Create ToolConfig

```
tool_config = ToolConfig(
 function_calling_config=ToolConfig.FunctionCallingConfig(
 mode=ToolConfig.FunctionCallingConfig.Mode.ANY,
 allowed_function_names=["get_current_weather_func"],
))
```
Use ToolConfig in `GenerativeModel.generate_content`:
```
model = GenerativeModel("gemini-pro")
print(model.generate_content(
 "What is the weather like in Boston?",
 # You can specify tools when creating a model to avoid having to send them with every request.
 tools=[weather_tool],
 tool_config=tool_config,
))
```
Use ToolConfig in chat:
```
model = GenerativeModel(
 "gemini-pro",
 # You can specify tools when creating a model to avoid having to send them with every request.
 tools=[weather_tool],
 tool_config=tool_config,
)
chat = model.start_chat()
print(chat.send_message("What is the weather like in Boston?"))
print(chat.send_message(
 Part.from_function_response(
 name="get_current_weather",
 response={
 "content": {"weather_there": "super nice"},
 }
 ),
))
```

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月30日 UTC.