Tool Calling· Lesson 1 of 7
What Is Tool Calling
In one line · Tool calling is giving the model a menu of tools it can request, so instead of guessing an answer it says 'call this tool with these inputs'.
This turns the model from a text-generating box into a brain that drives real systems — fetching live data, computing correctly, and acting beyond its words.
On its own the model can only talk. Give it tools and it's like an employee with a phone and a calculator on the desk: it asks you to run them and waits for the result.
Like a restaurant order: the model writes the order on a ticket, the kitchen (your code) fills it, and the dish comes back so it can continue.
You ask 'what's the weather in Cairo right now?' — the model doesn't know, but it requests a get_weather tool with city 'Cairo', and you run it and hand back the number.
You send the API the message plus your tool definitions. The model replies with one of two things: plain text, or a tool-call request — a structured block with the tool's name and JSON inputs. Note carefully: the model only requests; it never executes anything itself. Your code receives the request, validates the inputs, runs the real function, and returns the result to the model in a new message so it can continue based on it.
🧪 Try it yourself: write 5 user questions (e.g. 'explain what an API is', 'what's my balance?', 'write me a poem', 'the dollar rate right now?', 'delete my account'). For each, decide: plain text reply, or does the model need a tool? If a tool — what's its name and inputs?
Biggest mistake: believing the model 'runs' the tool itself. No — it generates JSON saying what it wants; execution is entirely on you. Second: passing the model's inputs straight into your execution code without validation, as if they were trusted data — they are not.
Use it when the model needs something outside its head: live data (prices, weather, a database), exact computation, or real actions (sending an email, opening a ticket).
Skip it when the ask is general knowledge or creative writing the model already handles alone — adding tools there just adds complexity and cost for nothing.