Tool Calling (Function Calling)

Gen AI function calling tools agents

The model that knows it doesn't know

An LLM is frozen in time and can't touch the outside world — it can't read today's weather, run code, or query your database. Tool calling gives it a way out: you describe some functions, and when a request needs one, the model emits a structured call instead of guessing. Your code runs the function and hands the result back, and the model finishes the answer.

You define tool schemas

Name, description and parameters for each function — what it does and what it needs.

Model decides call or answer

It chooses whether a tool is needed and fills in the arguments as JSON.

You execute run & return

Your code runs the real function and returns the result for the model to use.

The round-trip

Ask "What's the weather in Paris?". The model can't know — so it calls a tool, your code runs it, the result comes back, and only then does the model give a grounded answer.

From one tool to agents

Loop the round-trip and you get an agent

Give the model several tools and let it call them repeatedly — search, then read, then calculate, then answer — and you've built an AI agent. Tool calling is also how RAG retrieval and code execution get wired in. The model plans; your tools act.

Great for
  • Live data: weather, prices, search
  • Actions: send email, book, update a record
  • Exact math and code execution
Watch out
  • The model can pick the wrong tool or args
  • Validate inputs — treat calls as untrusted
  • Guard side-effects (don't auto-run risky actions)