Overview
You can use function calling to define custom functions and provide these to a generative AI model. While processing a query, the model can choose to delegate certain data processing tasks to these functions. It does not call the functions. Instead, it provides structured data output that includes the name of a selected function and the arguments that the model proposes the function to be called with. You can use this output to invoke external APIs. You can then provide the API output back to the model, allowing it to complete its answer to the query. When it is used this way, function calling enables LLMs to access real-time information and interact with various services, such as SQL databases, customer relationship management systems, and document repositories.
The following diagram illustrates how function calling works:
To learn about the use cases of function calling, see Use cases of function calling. To learn how to create a function calling application, see Create a function calling application. For best practices, see Best practices.
Model | Version | Function calling launch stage | Support for parallel function calling | Support for forced function calling |
---|---|---|---|---|
Gemini 1.0 Pro |
gemini-1.0-pro-001 |
General Availability | No | No |
Gemini 1.0 Pro |
gemini-1.0-pro-002 |
General Availability | No | No |
Gemini 1.5 Flash |
gemini-1.5-flash-001 |
General Availability | Yes | No |
Gemini 1.5 Pro |
gemini-1.5-pro-001 |
General Availability | Yes | Yes |
Use cases of function calling
You can use function calling for the following tasks:
- Extract entities from natural language stories: Extract lists of characters, relationships, things, and places from a story.
Vertex AI SDK for Python notebook - Structured data extraction using function calling - Query and understand SQL databases using natural language: Ask the model to convert questions such as
What percentage of orders are returned?
into SQL queries and create functions that submit these queries to BigQuery.
Blog post - Building an AI-powered BigQuery Data Exploration App using Function Calling in Gemini - Help customers interact with businesses: Create functions that connect to a business' API, allowing the model to provide accurate answers to queries such as
Do you have the Pixel 8 Pro in stock?
orIs there a store in Mountain View, CA that I can visit to try it out?
Vertex AI SDK for Python notebook - Function Calling with the Vertex AI Gemini API & Python SDK
REST sample | Vertex AI SDK for Python chat sample - Build generative AI applications by connecting to public APIs, such as:
- Convert between currencies: Create a function that connects to a currency exchange app, allowing the model to provide accurate answers to queries such as
What's the exchange rate for euros to dollars today?
Codelab - How to Interact with APIs Using Function Calling in Gemini - Get the weather for a given location: Create a function that connects to an API of a meteorological service, allowing the model to provide accurate answers to queries such as
What's the weather like in Paris?
Vertex AI SDK for Python notebook - Function Calling with the Vertex AI Gemini API & Python SDK
Blog post - Function calling: A native framework to connect Gemini to external systems, data, and APIs
Vertex AI SDK for Python and Node.js text samples | Node.js, Java, and Go chat samples - Convert an address to latitude and longitude coordinates: Create a function that converts structured location data into latitude and longitude coordinates. Ask the model to identify the street address, city, state, and postal code in queries such as
I want to get the lat/lon coordinates for the following address: 1600 Amphitheatre Pkwy, Mountain View, CA 94043, US.
Vertex AI SDK for Python notebook - Function Calling with the Vertex AI Gemini API & Python SDK
- Convert between currencies: Create a function that connects to a currency exchange app, allowing the model to provide accurate answers to queries such as
- Interpret voice commands: Create functions that correspond with in-vehicle tasks. For example, you can create functions that turn on the radio or activate the air conditioning. Send audio files of the user's voice commands to the model, and ask the model to convert the audio into text and identify the function that the user wants to call.
- Automate workflows based on environmental triggers: Create functions to represent processes that can be automated. Provide the model with data from environmental sensors and ask it to parse and process the data to determine whether one or more of the workflows should be activated. For example, a model could process temperature data in a warehouse and choose to activate a sprinkler function.
- Automate the assignment of support tickets: Provide the model with support tickets, logs, and context-aware rules. Ask the model to process all of this information to determine who the ticket should be assigned to. Call a function to assign the ticket to the person suggested by the model.
- Retrieve information from a knowledge base: Create functions that retrieve academic articles on a given subject and summarize them. Enable the model to answer questions about academic subjects and provide citations for its answers.
Create a function calling application
To enable a user to interface with the model and use function calling, you must create code that performs the following tasks:
- Define and describe a set of available functions using function declarations.
- Submit a user's query and the function declarations to the model.
- Invoke a function using the structured data output from the model.
- Provide the function output to the model.
You can create an application that manages all of these tasks. This application can be a text chatbot, a voice agent, an automated workflow, or any other program.
Define and describe a set of available functions
The application must declare a set of functions that the model can use to process the query. Each function declaration must include a function name and function parameters. We strongly recommend that you also include a function description in each function declaration.
Function name
The application and the model use the function name to identify the function.
For best practices related to the function name, see Best practices - Function name.
Function parameters
Function parameters must be provided in a format that's compatible with the OpenAPI schema.
Vertex AI offers limited support of the OpenAPI schema. The following
attributes are supported: type
, nullable
, required
, format
,
description
, properties
, items
, enum
. The following attributes are not
supported: default
, optional
, maximum
, oneOf
.
When you use curl, specify the schema using JSON. When you use the Vertex AI SDK for Python, specify the schema using a Python dictionary.
For best practices related to function parameters, see Best practices - Function parameters.
Function description
The model uses function descriptions to understand the purpose of the functions and to determine whether these functions are useful in processing user queries.
For best practices related to the function description, see Best practices - Function description.
Examples of function declarations
Simple declaration
The following is an example of a simple function declaration in Python:
get_current_weather_func = FunctionDeclaration(
name="get_current_weather",
description="Get the current weather in a given location",
parameters={
"type": "object",
"properties": {"location": {"type": "string", "description": "The city name of the location for which to get the weather."}},
},
)
Array of items
The following is an example of a function declaration with an array of items:
extract_sale_records_func = FunctionDeclaration(
name="extract_sale_records",
description="Extract sale records from a document.",
parameters={
"type": "object",
"properties": {
"records": {
"type": "array",
"description": "A list of sale records",
"items": {
"description": "Data for a sale record",
"type": "object",
"properties": {
"id": {"type": "integer", "description": "The unique id of the sale."},
"date": {"type": "string", "description": "Date of the sale, in the format of MMDDYY, e.g., 031023"},
"total_amount": {"type": "number", "description": "The total amount of the sale."},
"customer_name": {"type": "string", "description": "The name of the customer, including first name and last name."},
"customer_contact": {"type": "string", "description": "The phone number of the customer, e.g., 650-123-4567."},
},
"required": ["id", "date", "total_amount"],
},
},
},
"required": ["records"],
},
)
Submit the query and the function declarations to the model
When the user provides a prompt, the application must provide the model with the user prompt and the function declarations. To configure how the model generates results, the application can provide the model with a generation configuration. To configure how the model uses the function declarations, the application can provide the model with a tool configuration.
User prompt
The following is an example of a user prompt: "What is the weather like in Boston?"
For best practices related to the user prompt, see Best practices - User prompt.
Generation configuration
The model can generate different results for different parameter values. The
temperature parameter controls the degree of randomness in this generation.
Lower temperatures are good for functions that require deterministic parameter
values, while higher temperatures are good for functions with parameters that
accept more diverse or creative parameter values. A temperature of 0
is
deterministic. In this case, responses for a given prompt are mostly
deterministic, but a small amount of variation is still possible. To learn
more, see Gemini API.
To set this parameter, submit a generation configuration (generation_config
)
along with the prompt and the function declarations. You can update the
temperature
parameter during a chat conversation using the Vertex AI
API and an updated generation_config
. For an example of setting the
temperature
parameter, see
How to submit the prompt and the function declarations.
For best practices related to the generation configuration, see Best practices - Generation configuration.
Tool configuration
You can place some constraints on how the model should use the function declarations that you provide it with. For example, instead of allowing the model to choose between a natural language response and a function call, you can force it to only predict function calls ("forced function calling"). You can also choose to provide the model with a full set of function declarations, but restrict its responses to a subset of these functions.
To place these constraints, submit a tool configuration (tool_config
) along
with the prompt and the function declarations. In the configuration, you can
specify one of the following modes:
Mode | Description |
---|---|
AUTO | The default model behavior. The model decides whether to predict a function call or a natural language response. |
ANY | The model must predict only function calls. To limit the model to a subset of functions, define the allowed function names in allowed_function_names . |
NONE | The model must not predict function calls. This behaviour is equivalent to a model request without any associated function declarations. |
The tool configuration's ANY
mode ("forced function calling") is a Preview
feature. It is supported for
Gemini 1.5 Pro
models only.
To learn more, see Function Calling API.
How to submit the prompt and the function declarations
The following is an example of how can you submit the query and the function
declarations to the model, and constrain the model to predict only
get_current_weather
function calls.
# Initialize Vertex AI
from vertexai.preview.generative_models import ToolConfig
vertexai.init(project=project_id, location=location)
# Initialize Gemini model
model = GenerativeModel("Gemini 1.5 Pro")
# Define a tool that includes the function declaration get_current_weather_func
weather_tool = Tool(
function_declarations=[get_current_weather_func],
)
# Define the user's prompt in a Content object that we can reuse in model calls
user_prompt_content = Content(
role="user",
parts=[
Part.from_text(prompt),
],
)
# Send the prompt and instruct the model to generate content using the Tool object that you just created
response = model.generate_content(
user_prompt_content,
generation_config={"temperature": 0},
tools=[weather_tool],
tool_config=ToolConfig(
function_calling_config=ToolConfig.FunctionCallingConfig(
# ANY mode forces the model to predict a function call
mode=ToolConfig.FunctionCallingConfig.Mode.ANY,
# Allowed functions to call when the mode is ANY. If empty, any one of
# the provided functions are called.
allowed_function_names=["get_current_weather"],
))
)
response_function_call_content = response.candidates[0].content
If the model determines that it needs the output of a particular function, the response that the application receives from the model contains the function name and the parameter values that the function should be called with.
The following is an example of a model response to the user prompt "What is the weather like in Boston?". The model proposes calling
the get_current_weather
function with the parameter Boston, MA
.
candidates { content { role: "model" parts { function_call { name: "get_current_weather" args { fields { key: "location" value { string_value: "Boston, MA" } } } } } } ... }
For prompts such as "Get weather details in New Delhi and San Francisco?",
the model may propose several parallel function calls. Parallel function calling
is a Preview feature. It's supported by the
Gemini 1.5 Pro
and Gemini 1.5 Flash
models. To learn more, see
Parallel function calling example.
Invoke an external API
If the application receives a function name and parameter values from the model, the application must connect to an external API and call the function.
The following example uses synthetic data to simulate a response payload from an external API:
# Check the function name that the model responded with, and make an API call to an external system
if (
response.candidates[0].content.parts[0].function_call.name
== "get_current_weather"
):
# Extract the arguments to use in your API call
location = (
response.candidates[0].content.parts[0].function_call.args["location"]
)
# Here you can use your preferred method to make an API request to fetch the current weather, for example:
# api_response = requests.post(weather_api_url, data={"location": location})
# In this example, we'll use synthetic data to simulate a response payload from an external API
api_response = """{ "location": "Boston, MA", "temperature": 38, "description": "Partly Cloudy",
"icon": "partly-cloudy", "humidity": 65, "wind": { "speed": 10, "direction": "NW" } }"""
For best practices related to API invocation, see Best practices - API invocation.
Provide the function output to the model
After an application receives a response from an external API, the application must provide this response to the model. The following is an example of how you can do this using Python:
response = model.generate_content(
[
user_prompt_content, # User prompt
response_function_call_content, # Function call response
Content(
parts=[
Part.from_function_response(
name="get_current_weather",
response={
"content": api_response, # Return the API response to Gemini
},
)
],
),
],
tools=[weather_tool],
)
# Get the model summary response
summary = response.candidates[0].content.parts[0].text
If the model had proposed several parallel function calls, the application must
provide all of the responses back to the model. Parallel function calling is a
Preview feature. It's supported by the
Gemini 1.5 Pro
and Gemini 1.5 Flash
models. To learn more, see
Parallel function calling example.
gemini-1.0-pro-001
and gemini-1.0-pro-002
models may determine that the
output of another function is necessary for answering the query. In this case,
the response that the application receives from the model contains another
function name and another set of parameter values.
If the model determines that the API response is sufficient for answering the
user's query, it creates a natural language response and returns it to the
application. In this case, the application must pass the response back to the
user. The following is an example of a query response:
It is currently 38 degrees Fahrenheit in Boston, MA with partly cloudy skies. The humidity is 65% and the wind is blowing at 10 mph from the northwest.
Best practices
Function name
Don't use period (.
), dash (-
), or space characters in the function name.
Instead, use underscore (_
) characters or any other characters.
Function parameters
Write clear and verbose parameter descriptions, including details such as your
preferred format or values. For example, for
a book_flight_ticket
function:
- The following is a good example of a
departure
parameter description:Use the 3 char airport code to represent the airport. For example, SJC or SFO. Don't use the city name.
- The following is a bad example of a
departure
parameter description:the departure airport
If possible, use strongly typed parameters to reduce model hallucinations. For
example, if the parameter values are from a finite set, add an enum
field
instead of putting the set of values into the description. If the parameter
value is always an integer, set the type to integer
rather than number
.
Function description
Write function descriptions clearly and verbosely. For example, for a
book_flight_ticket
function:
- The following is an example of a good function description:
book flight tickets after confirming users' specific requirements, such as time, departure, destination, party size and preferred airline
- The following is an example of a bad function description:
book flight ticket
User prompt
For best results, prepend the user query with the following details:
- Additional context for the model-for example,
You are a flight API assistant to help with searching flights based on user preferences.
- Details or instructions on how and when to use the functions-for example,
Don't make assumptions on the departure or destination airports. Always use a future date for the departure or destination time.
- Instructions to ask clarifying questions if user queries are ambiguous-for example,
Ask clarifying questions if not enough information is available.
Generation configuration
For the temperature parameter, use 0
or another low value. This instructs
the model to generate more confident results and reduces hallucinations.
API invocation
If the model proposes the invocation of a function that would send an order, update a database, or otherwise have significant consequences, validate the function call with the user before executing it.
Pricing
The pricing for function calling is based on the number of characters within the text inputs and outputs. To learn more, see Vertex AI pricing.
Here, text input (prompt) refers to the user query for the current conversation turn, the function declarations for the current conversation turn, and the history of the conversation. The history of the conversation includes the queries, the function calls, and the function responses of previous conversation turns. Vertex AI truncates the history of the conversation at 32,000 characters.
Text output (response) refers to the function calls and the text responses for the current conversation turn.
Function calling samples
You can use function calling to generate a single text response or to support a chat session. Ad hoc text responses are useful for specific business tasks, including code generation. Chat sessions are useful in freeform, conversational scenarios, where a user is likely to ask follow-up questions.
If you use function calling to generate a single response, you must provide the model with the full context of the interaction. On the other hand, if you use function calling in the context of a chat session, the session stores the context for you and includes it in every model request. In both cases, Vertex AI stores the history of the interaction on the client side.
To learn how to use function calling to generate a single text response, see Text examples. To learn how to use function calling to support a chat session, see Chat examples. For a sample that demonstrates parallel function calling, see Parallel function calling example.
Text examples
Python
This example demonstrates a text scenario with one function and one
prompt. It uses the GenerativeModel
class and its methods. For more
information about using the Vertex AI SDK for Python with Gemini multimodal
models, see
Introduction to multimodal classes in the Vertex AI SDK for Python.
To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python.
For more information, see the
Python API reference documentation.
Python
Node.js
This example demonstrates a text scenario with one function and one prompt.
REST
This example demonstrates a text scenario with three functions and one prompt.
In this example, you call the generative AI model twice.
- In the first call, you provide the model with the prompt and the function declarations.
- In the second call, you provide the model with the API response.
First model request
The request must define a query in the text
parameter. This example defines
the following query: "Which theaters in Mountain View show the Barbie movie?".
The request must also define a tool (tools
) with a set of function
declarations (functionDeclarations
). These function declarations must be
specified in a format that's compatible with the
OpenAPI schema. This example
defines the following functions:
find_movies
finds movie titles playing in theaters.find_theatres
finds theaters based on location.get_showtimes
finds the start times for movies playing in a specific theater.
To learn more about the parameters of the model request, see Gemini API.
Replace my-project with the name of your Google Cloud project.
First model request
PROJECT_ID=my-project MODEL_ID=gemini-1.0-pro API=streamGenerateContent curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" https://us-central1-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${MODEL_ID}:${API} -d '{ "contents": { "role": "user", "parts": { "text": "Which theaters in Mountain View show the Barbie movie?" } }, "tools": [ { "function_declarations": [ { "name": "find_movies", "description": "find movie titles currently playing in theaters based on any description, genre, title words, etc.", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616" }, "description": { "type": "string", "description": "Any kind of description including category or genre, title words, attributes, etc." } }, "required": [ "description" ] } }, { "name": "find_theaters", "description": "find theaters based on location and optionally movie title which are is currently playing in theaters", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616" }, "movie": { "type": "string", "description": "Any movie title" } }, "required": [ "location" ] } }, { "name": "get_showtimes", "description": "Find the start times for movies playing in a specific theater", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616" }, "movie": { "type": "string", "description": "Any movie title" }, "theater": { "type": "string", "description": "Name of the theater" }, "date": { "type": "string", "description": "Date for requested showtime" } }, "required": [ "location", "movie", "theater", "date" ] } } ] } ] }'
For the prompt "Which theaters in Mountain View show the Barbie movie?", the model
might return the function find_theatres
with parameters Barbie
and
Mountain View, CA
.
Response to first model request
[{ "candidates": [ { "content": { "parts": [ { "functionCall": { "name": "find_theaters", "args": { "movie": "Barbie", "location": "Mountain View, CA" } } } ] }, "finishReason": "STOP", "safetyRatings": [ { "category": "HARM_CATEGORY_HARASSMENT", "probability": "NEGLIGIBLE" }, { "category": "HARM_CATEGORY_HATE_SPEECH", "probability": "NEGLIGIBLE" }, { "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "probability": "NEGLIGIBLE" }, { "category": "HARM_CATEGORY_DANGEROUS_CONTENT", "probability": "NEGLIGIBLE" } ] } ], "usageMetadata": { "promptTokenCount": 9, "totalTokenCount": 9 } }]
Second model request
This example uses synthetic data instead of calling the external API.
There are two results, each with two parameters (name
and address
):
name
:AMC Mountain View 16
,address
:2000 W El Camino Real, Mountain View, CA 94040
name
:Regal Edwards 14
,address
:245 Castro St, Mountain View, CA 94040
Replace my-project with the name of your Google Cloud project.
Second model request
PROJECT_ID=my-project MODEL_ID=gemini-1.0-pro API=streamGenerateContent curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" https://us-central1-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${MODEL_ID}:${API} -d '{ "contents": [{ "role": "user", "parts": [{ "text": "Which theaters in Mountain View show the Barbie movie?" }] }, { "role": "model", "parts": [{ "functionCall": { "name": "find_theaters", "args": { "location": "Mountain View, CA", "movie": "Barbie" } } }] }, { "parts": [{ "functionResponse": { "name": "find_theaters", "response": { "name": "find_theaters", "content": { "movie": "Barbie", "theaters": [{ "name": "AMC Mountain View 16", "address": "2000 W El Camino Real, Mountain View, CA 94040" }, { "name": "Regal Edwards 14", "address": "245 Castro St, Mountain View, CA 94040" }] } } } }] }], "tools": [{ "functionDeclarations": [{ "name": "find_movies", "description": "find movie titles currently playing in theaters based on any description, genre, title words, etc.", "parameters": { "type": "OBJECT", "properties": { "location": { "type": "STRING", "description": "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616" }, "description": { "type": "STRING", "description": "Any kind of description including category or genre, title words, attributes, etc." } }, "required": ["description"] } }, { "name": "find_theaters", "description": "find theaters based on location and optionally movie title which are is currently playing in theaters", "parameters": { "type": "OBJECT", "properties": { "location": { "type": "STRING", "description": "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616" }, "movie": { "type": "STRING", "description": "Any movie title" } }, "required": ["location"] } }, { "name": "get_showtimes", "description": "Find the start times for movies playing in a specific theater", "parameters": { "type": "OBJECT", "properties": { "location": { "type": "STRING", "description": "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616" }, "movie": { "type": "STRING", "description": "Any movie title" }, "theater": { "type": "STRING", "description": "Name of the theater" }, "date": { "type": "STRING", "description": "Date for requested showtime" } }, "required": ["location", "movie", "theater", "date"] } }] }] }'
The model's response might be similar to the following:
Response to second model request
{ "candidates": [ { "content": { "parts": [ { "text": " OK. Barbie is showing in two theaters in Mountain View, CA: AMC Mountain View 16 and Regal Edwards 14." } ] } } ], "usageMetadata": { "promptTokenCount": 9, "candidatesTokenCount": 27, "totalTokenCount": 36 } }
Chat examples
Python
This example demonstrates a chat scenario with two functions and two
sequential prompts. It uses the GenerativeModel
class and its methods. For
more information about using the Vertex AI SDK for Python with multimodal models, see
Introduction to multimodal classes in the Vertex AI SDK for Python.
To learn how to install or update Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.
Java
Before trying this sample, follow the Java setup instructions in the Vertex AI quickstart using client libraries. For more information, see the Vertex AI Java API reference documentation.
To authenticate to Vertex AI, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
Before trying this sample, follow the Go setup instructions in the Vertex AI quickstart using client libraries. For more information, see the Vertex AI Go API reference documentation.
To authenticate to Vertex AI, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Parallel function calling example
REST
This example demonstrates a scenario with one get_current_weather
function.
The user prompt is "Get weather details in New Delhi and San Francisco?". The
model proposes two parallel get_current_weather
function calls: one with the
parameter New Delhi
and the other with the parameter San Francisco
.
Parallel function calling is a Preview
feature. It's supported by the
Gemini 1.5 Pro
and Gemini 1.5 Flash
models.
To learn more about the parameters of the model request, see Gemini API.
candidates { content { role: "model" parts: [ { function_call { name: "get_current_weather" args { fields { key: "location" value { string_value: "New Delhi" } } } } }, { function_call { name: "get_current_weather" args { fields { key: "location" value { string_value: "San Francisco" } } } } } ] } ... }
The following command demonstrates how you can provide the function output to the model. Replace my-project with the name of your Google Cloud project.
Model request
PROJECT_ID=my-project MODEL_ID=gemini-1.5-pro-001 VERSION="v1" LOCATION="us-central1" ENDPOINT=${LOCATION}-aiplatform.googleapis.com API="generateContent" curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" https://${ENDPOINT}/${VERSION}/projects/${PROJECT_ID}/locations/${LOCATION}/publishers/google/models/${MODEL_ID}:${API} -d '{ "contents": [ { "role": "user", "parts": { "text": "What is difference in temperature in New Delhi and San Francisco?" } }, { "role": "model", "parts": [ { "functionCall": { "name": "get_current_weather", "args": { "location": "New Delhi" } } }, { "functionCall": { "name": "get_current_weather", "args": { "location": "San Francisco" } } } ] }, { "role": "user", "parts": [ { "functionResponse": { "name": "get_current_weather", "response": { "temperature": 30.5, "unit": "C" } } }, { "functionResponse": { "name": "get_current_weather", "response": { "temperature": 20, "unit": "C" } } } ] } ], "tools": [ { "function_declarations": [ { "name": "get_current_weather", "description": "Get the current weather in a specific location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616" } }, "required": [ "location" ] } } ] } ] }'
The natural language response created by the model is similar to the following:
Model response
[ { "candidates": [ { "content": { "parts": [ { "text": "The temperature in New Delhi is 30.5C and the temperature in San Francisco is 20C. The difference is 10.5C. \n" } ] }, "finishReason": "STOP", ... } ] ... } ]