Tune function calling

Function callinglets you create Gemini-based applications and agentsthat can interact with real-time information and services like databases,customer relationship management systems, and document repositories. Thisenhances your application's ability to provide relevant and contextualresponses.

With supervised fine-tuning, you can useyour own tuning datasetto improve the overall accuracy of your application's function calling-basedresponses.

Tuning dataset format

ThefileUri for your fine-tuning dataset can be the URI for a file in aCloud Storage bucket, or it can be a publicly available HTTP or HTTPS URL.

To see the generic format example, see thedataset example for Gemini.

The following sections present examples of function calling datasets for usein creating a tuning job for function calling.

Tuning function calling to generate text

The following is an example of a dataset for tuningfunction calling to generate a single text response.

{"system_instruction":{"role":"system","parts":[{"text":"You are an assistant that helps users find the best product for them."}]},"contents":[{"role":"user","parts":[{"text":"Do you have the White Pixel 8 Pro 128GB in stock in the US?"}]},{"role":"model","parts":[{"functionCall":{"name":"get_product_sku","args":{"product_name":"Pixel 8 Pro 128GB"}}}]}],"tools":[{"functionDeclarations":[{"name":"get_product_sku","description":"Get the available inventory for a Google products, e.g: Pixel phones, Pixel Watches, Google Home etc","parameters":{"type":"OBJECT","properties":{"product_name":{"type":"STRING","description":"Product name","enum":["Pixel 8 Pro 128GB","Pixel 8 Pro 256GB","Pixel 8 Pro 512GB","Pixel 8 Pro 1TB"]}}}},{"name":"get_store_location","description":"Get the location of the closest store","parameters":{"type":"OBJECT","properties":{"location":{"type":"STRING","description":"Location"}}}}]}]}

Tuning function calling to support a chat session

The following is an example of a dataset for tuningfunction calling to support a chat session.

{"system_instruction":{"role":"system","parts":[{"text":"You are an assistant that helps users find the best product for them."}]},"contents":[{"role":"user","parts":[{"text":"Do you have the Porcelain Pixel 8 Pro 128GB in stock in the US?"}]},{"role":"model","parts":[{"functionCall":{"name":"get_product_sku","args":{"product_name":"Pixel 8 Pro 128GB"}}}]},{"parts":[{"functionResponse":{"name":"get_product_sku","response":{"output":"True"}}}]},{"role":"model","parts":[{"text":"Yes, we have the Porcelain Pixel 8 Pro 128GB in stock in the US."}]}],"tools":[{"functionDeclarations":[{"name":"get_product_sku","description":"Get the available inventory for a Google products, e.g: Pixel phones, Pixel Watches, Google Home etc","parameters":{"type":"OBJECT","properties":{"product_name":{"type":"STRING","description":"Product name","enum":["Pixel 8 Pro 128GB","Pixel 8 Pro 256GB","Pixel 8 Pro 512GB","Pixel 8 Pro 1TB"]}}}},{"name":"get_store_location","description":"Get the location of the closest store","parameters":{"type":"OBJECT","properties":{"location":{"type":"STRING","description":"Location"}}}}]}]}

Tuning parallel function calling

The following is an example of a dataset for tuningparallel function calling.

{"system_instruction":{"role":"system","parts":[{"text":"You are an assistant that helps users find the best product for them."}]},"contents":[{"role":"user","parts":[{"text":"Where is the closest Google Store to Mountain View, CA that has Pixel 8 Pro 128GB in stock?"}]},{"role":"model","parts":[{"functionCall":{"name":"get_product_sku","args":{"product_name":"Pixel 8 Pro 128GB"}}},{"functionCall":{"name":"get_store_location","args":{"location":"Mountain View, CA"}}}]}],"tools":[{"functionDeclarations":[{"name":"get_product_sku","description":"Get the available inventory for a Google products, e.g: Pixel phones, Pixel Watches, Google Home etc","parameters":{"type":"OBJECT","properties":{"product_name":{"type":"STRING","description":"Product name","enum":["Pixel 8 Pro 128GB","Pixel 8 Pro 256GB","Pixel 8 Pro 512GB","Pixel 8 Pro 1TB"]}}}},{"name":"get_store_location","description":"Get the location of the closest store","parameters":{"type":"OBJECT","properties":{"location":{"type":"STRING","description":"Location"}}}}]}]}

What's next

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

Last updated 2026-02-19 UTC.