Gemini 2.5 Pro Function Calling—All You Need to Know

LARRUZ shows how to use Gemini 2.5 Pro for function calling and agents. Build a text-to-SQL assistant, a trip planner that chains multiple steps, and a dashboard that queries both databases and market data. Learn system prompt design and the model's practical limits.
Questions this video answers
Five requests per minute and 50 requests per day (free API).
Input context up to 1,000,000 tokens; output generation up to 65,000 tokens.
Gemini 2.5 Pro experimental 0325.
"The knowledge cutoff date is January 2020 25." (as spoken in the video).
Polyglot 8R benchmark; presenter mentions about a ~6-point improvement over previous generation models.
Chapters
I'm assuming by now that you have seen all the hype around Gemini 2.5 Pro based on the benchmarks and some of the results that people have been sharing. But now we finally have some independent benchmarks coming in, especially on the live bench. This seems to be the best model out there and by a huge margin we are talking about almost six points. And even in terms of coding, this seems to be really good, much better than the previous generation of models on the Polyglot 8R benchmark. The Independent results actually confirm what they have reported. So overall this seems to be really good at coding. So I want to put this model to a test, but we're not going to be building any games or asking it to do single shot things. I'd build a lot of agents and one of the critical component of any Agentix system is for the LLM to have the ability to correctly call functions. So I want to see how good this new model is at function calling. We're going to start with basic function calling. Then we're going to look at its ability to do parallel function calls, which are very useful in building practical applications. Then I'm going to show you how you can build a text to SQL Assistant with this model. It's going to be a very basic example, but the thing that I am actually excited about trying is when we combine this text to SQL system with parallel function calls to unstructured data, that actually shows you the real power of a good coding LLM. Okay, so before showing you the code, just a very quick basic recap on function calling. If you have seen some of my previous videos on this topic, you probably have seen this, but essentially an agent has a set of tools available for it to interact with real world. So that could be do mathematics, do web search, lookup weather, and so on and so forth. When the user query comes in, the LLM or agent has to decide whether it needs to use an external tool or it can answer user query based on its internal knowledge, that is the training data. If it does not need any external tools, the LLM generates the response and we show that response to the user. But if it does need a tool, it will pick the appropriate tool, also generate appropriate inputs to that tool or function, get a response from that, use that to generate a final response to the user. So that's usually the normal flow of how function calling works. Now usually the user has to control the execution, like make the function calls and then feed that response back to the LLM. But the Gemini SDK for Python can do all of this automatically, but it also gives you the flexibility to do the manual function calling if you need to. So that's a really good feature. In this video we are going to be relying on the automated function calling built into the Google SDK. So first we need to install the Google SDK, then set up your API key. You can also use the vertex version if you want to use Vertex AI. But in my case I'm going to be just focusing on the AI studio. Now if you go to AI studio and you choose Gemini 2.5, this model is available for free. The knowledge cutoff date is January 2020 25. So it's a recently trained model with probably the most up to date knowledge. One thing to keep in mind is the rate limits. Right now With a free API you can make five requests per minute or a total of 50 requests per day. But something that not a lot of people are highlighting is its huge context window and not only the input of 1 million tokens, but it can generate up to 65,000 tokens at output, which is really great, especially if you are working with huge code bases. Okay, so for our code we are going to be using Gemini 2.5 Pro experimental 0325. Now we can make a simple call to the LLM, something like what is the weather like in San Francisco? The output JSON dictionary that you get is, is going to have a key called text. And here is the response that you get. Essentially it says, I cannot provide real time, up to the minute updates like a dedicated weather app or website. Right. So it knows its limitations. The API also gives you the model number, how many tokens were used in total, what were the total number of input tokens and the total number of output tokens. Right. Now one more thing is that the API does not give you the chain of thought, which is a bummer. It would be great if we could get that. But it's also understandable because if the API is giving you chain of thought, people could train models on that chain of thought. So that might be one of the thinking behind this decision. Now you also get information about tool use, prompt tokens count. So you can already see that it has the ability to generate structured outputs and then do tool calling. Okay, so let's start with a very basic and simple function call. So just like everybody else, I have a function called get current weather. It doesn't make any API call. The only thing that it returns is this dummy data. If somebody mentioned San Francisco, it's going to say foggy 15 degrees Celsius, New York. Then it's going to say sunny, 22 degrees Celsius. If you provide any other location, it's going to just return partly cloudy and 20 degrees Celsius. That's essentially a simple function that we implement. Now, within the function description, we add a doc string which tells the model what exactly this function does and what are the expected inputs. Now, to use this as a tool, it's very simple to do. So we'll have the same structure. The only thing we add is this config which has a list of tools. Right now we're using a single tool, so we just provide that tool here. Now if I ask what is the weather like in San Francisco? It says the weather in San Francisco is currently foggy with a temperature of 15 degrees Celsius. In real world applications, you're going to have an API call and you will just return the API data. So if we look at the output, we can actually see what exactly happened here. So these are the different candidates, or think about it, different roles. So here's the user question. Then we can actually see what were the number of input tokens. Output tokens. Right. Then it also added the automatic function calling history. So when it got that user input, it looks at available functions and it decides that I can call the getweather function. The input is supposed to be San Francisco, which is the location, and it gets the response and use that response to generate the final output for the user. Okay, and here's just another example of what the function call looks like. Now that was a simple function call where the LLM has access to a single tool. But let's say if you have multiple tools and we want the LLM to make multiple parallel functions calls. So here we have the same getcurrent weather function. Now we have yet another function which is get population, and we add these two tools or functions to the tool set. So in this case, our prompt is compare the weather and population of New York and San Francisco. It goes first, picks up the weather information for both the cities, also picks up the population information for both the cities. And, and then it says New York is currently warmer than San Francisco and it has a significantly larger population. Right. So it's able to execute those two function calls for these two queries, and it doesn't seem to have any issues with relatively complex queries. And you can see here is where the parallel function call was actually happening. Now, instead of two functions, you can have a lot more functions. I'll show you an example later in the Video, but so far I haven't really seen it struggle at all, which is really good news, especially if you're planning on building agents on top of Gemini 2.5 Pro. Okay, so the next one is going to be building SQL Assistant. So this is basically an example of the LLM or agent interacting with the database. Again, a very simple example in the current form, but we are going to expand on this later in the video. The idea would be the user asks natural language queries, and then the LLM will convert those natural language queries into SQL queries that it can execute or a SQL database. So we're going to be using SQLite for this. Here is the sample database description. Here's the data that we want to put into the database. And the data has four different columns. First is the employee number name, their department and their corresponding salaries. Now we expect the model to get natural language query and generate a SQL query. So we have this function called Execute SQL Query that is going to receive SQL query from the LLM executed, return the results, and those results are going to be used by the LLM to generate the final response. So very similar to what we saw for that weather example, we pass this Execute SQL query function as a tool. Now, in this case we have a system prompt which tells it always check the database schema first. The database has an employees table with these columns, right? Later I'll show you how to automatically extract the schema from a given table. But our query is what are the average salaries by department? And it's able to execute that query. It returns us the average salaries. For finance, it's 88,000 HR charge is 65,000. For engineering there are two entries. So it takes the average of those and returns us the results. If you look at what exactly happened here, here is the intermediate SQL query that it generated based on the user input. Now, as we go along in this video, we're going to be building on these simple examples into a more complex situation. So here's just one example. Let's say we want to look at some company's relative news and then decide whether we want to invest in that company or not, right? So a simple example here is we have a function that gets the news related to different companies. I created a dictionary here where there are different news articles for Apple, Microsoft and Google. There is another function which will get a news and then the this decides what is the actual sentiment around it, right? And the sentiment is basically determined by whether there are these positive words or negative words, right? So we pass on These two tools to our agent and here's the user question. What is the recent news about Apple and what's the journal sentiment? So now it first uses the get company news function to get the news articles, then passes on those to the sentiment analyzer function. Get the final response from that, feed that into the LLM and the output is okay, I found two news articles about Apple. These are the news articles and overall then it says that the sentiment is neutral based on these two articles. Okay, so now we're going to start looking at some more complex examples which are going to be more representative of real world use cases. So the first one is a trip planning with complex function calling. So let's say you want to plan a trip that is going to involve multiple different steps and you want an agent to help you out. Here we have a number of different functions. So for example, the first one is get weather information and instead of using an external API again I am just hard coding that information. Then there's another function which is going to search for flights depending on what is the destination origin plus the dates of flight. Then we have search hotels. Think of these functions as separate API calls where you get certain input, you make the API call, the API returns some data and the LLM is going to be using that data to generate the final response. So there's another function for currency conversion and for trip planning. Right. So in total right now I have six different functions and each one of them is going to be treated as a tool. Now my query is I am planning a trip from New York to Paris from April 10 to 13, 2025. I need help with finding flights from New York to Paris on the April 10, checking the weather during my stay, recommending hotels for two people, then planning for a daily itinerary. And here's my total budget. Right? So in general you would use different API calls to answer these things individually and you want to do them sequentially so that the output of the first fog API goes as an input to the second one. Right? So the agent or LLM has to have the ability to sequentially execute these functions. And we tell it in system instruction. You are a travel planner assistant help user plan trip by using available tools to gather information and these are the things that it can help with. Okay, so now based on our complex query, here is the plan that he came up with. So the destination is Paris, origin is New York. These are the dates it's suggested different flights plus also tells us the weather information. Here are a couple of hotel recommendation and then it tries that. Okay. Based on the given budget, what the total expenses are going to look like if you convert it to euros. There was a currency conversion function or tool, right? And then it also looks at all the attractions that are available. And based on that, it also generated a daily list of activities that you can perform. Again, we can look at what exactly happened and what were the total number of tokens. It's about 3,400 tokens now. So here's the initial user question. Then the first response from the model is, okay, I can help you plan the trip to Paris from New York. I'll gather the flight options, weather forecast, hotel suggestions, and create a possible itinerary and convert your budget amount. So this is the first thing that the LLM generates. Now, it doesn't show it to the user yet because it has to make all these function calls. So actually it's able to execute all of the function calls, gather information from each one of them, then sequentially pass it on to the other one. And then from that it is able to formulate the final response. And in this case it's both doing sequential function calls as well as parallel function calls. Now the only thing that is missing, which I would love to see, is the internal chain of thought, how exactly it decided what sequence to use. I wish Google would enable that through the API. That is going to be extremely helpful for developers. Okay, this last example will combine everything that we have seen so far. So in this case we are trying to build a business intelligent dashboard where the user can ask questions in natural language. There is going to be a database that needs to be accessed using text to SQL and they're going to be also tools that are going to generate unstructured outputs. So let me walk you through what this looks like in terms of the functions. So instead of a single table, now we have multiple different tables and each of these table contains a different set of information. So for example, there's a sales table, product table, regions table, employees table, and we have randomly generated data. This is probably a better representative of what type of data you might actually encounter in real world. So we randomly generated samples based on those tables. We put them in the database. Now we have a SQL query executioner, very similar to what we saw before. Then there's a function to get the schema of the company database. This will automatically get the table name and get the corresponding schema. Then we have another data source. This is get market data. So let's say the company has some access to market data based on their sales and that is populated here. Then there's another function for analyzing sales trends. Again this is a SQL query that will help us analyze different trends in the data. And here's another function which provides competitive analysis for different product categories. So we generate the inputs and this is just dummy data which will give us the computer analysis. We have six different tools, each one of them is doing a very specific task. Here is the user, query it and imagine you are a business executive. So these are the type of questions you are potentially asking. I need a comprehensive analysis of our electronics product category. So it needs to figure out what category the user is talking about. Now there are multiple things that the agent needs to do. So one is how are our electronics sales doing compared to other categories? What's the market outlook for electronics? And who, who are our main competitors in this space? So this is the user input or user request. Now we have the system prompt. You need to pay very close attention to the system prompt and you want to spend a lot of time crafting it because this will control the behavior of your agent. So in this case the prompt is you are a business intelligence assistant with access to company data and market intelligence. When user asks about company performance and market conditions, then first query the database using SQL to retrieve internal company data. Then get relevant external market and computer data using function calls and then present a well structured analysis with data backed insights. Now something which I highly recommend doing is give step by step instructions of how the system is supposed to behave. Do not rely on the probabilistic nature of LLMs to make its own decision. You need to give it a plan and then you hope that it will stick to that plan. Especially for the bigger reasoning models they can stick to a plan if the plan is well crafted. So we provide that. We also provide some insights on what the different databases looks like. Now here's the output. It says I have the competitive analysis for electronics category. So first it figured out who are the main competitors in that space. Then it says the competitive advantages characterized by high barriers to entry, rapid innovation cycles. This is the information that is coming in from the market analysis. So then it generates the summary and analysis based on the information that it has gathered so far. Now if we look at the internal step by step execution. Here's the user input. Now here it decides that I can help you with that. I'll gather internal sales, external market outlook and computer information for the electronics category. Then it generates a SQL query to gather that information specifically for the electronics category. You can see the results that it receives it passed those on to another function. So it says, okay, I have the internal sales data comparing electronics to other categories based on the user query or based on the database query. So here's the database query that it generated. So it gets that information, then it basically use that information, pass it on to the second step, right? And you can see that using the step by step approach with all the information that it's gathering is able to generate a pretty comprehensive response. Now keep in mind this is just a starting example. In real world enterprise data is a lot more messy, a lot more complex. So you first want to spend some time understanding that data and then you want to craft your agent's behavior around that data. Again, you do not want to rely too much on the agent's ability to make or make an appropriate plan and then execute it. My recommendation would be to give it a step by step instructions on how exactly it can execute those. So basically it's going to be more of a workflow that the agent has to follow rather than coming up with a stochastic plan. If you're a business and you're trying to solve similar problems and are looking for advice and help, I am now starting to offer my consulting and advising services again. So do reach out. Details are in the video Description. Anyways, Gemini 2.5 Pro is indeed a very powerful model and I think especially for reasoning capabilities, combined with its coding abilities, it's really good model for complex workflows. So do check it out. Anyways, I hope you found this video useful. Thanks for watching and as always, see you in the next one.










