An LLM is very good at understanding and generating language. But what if we want it to do something outside the model?
For example:
What is the current price of Product A?
The LLM should not guess these answers. It needs access to another system. This is where Tool Calling, also called Function Calling, comes in.
What Is Tool Calling?
Tool Calling allows an LLM to request the use of an external function or service. A tool could be a search engine, a database, an API, a calculator, an email service, an internal business system and so on.
For example, our application might have a function like this:
def get_product_price(product_id):
...
Now imagine the user asks "What is the current price of product 12345?". The LLM understands that it needs current price data. Instead of making up an answer, it can request get_product_price(product_id="12345").
Who Actually Runs the Tool?
This is an important point. The LLM usually does not execute the function itself. The LLM decides which tool it needs and what information to request. The application actually executes the tool. Then the result is sent back to the LLM.
Why Tool Calling Matters
Without tools, an LLM mainly works with information already available in its context. With tools, it can connect to the outside world. A useful way to think about it is: LLM = Brain and Tools = Hands. The model can reason about what needs to happen, while tools allow the application to retrieve data or perform actions. But tools are not the only way to give an LLM information. Sometimes we have thousands of documents that the model needs to search. For that, we need RAG. That is what we’ll cover in the next post.