How does a tool call actually happen between an LLM and an external API?

The model never touches the API. It only writes the order slip.

Picture it first

In a restaurant, you (the model) can't go into the kitchen. You write your order on a slip: '1 masala dosa, extra chutney'. The waiter (the app) takes the slip to the kitchen (the API), brings back the food (the result), and puts it on your table. Then you decide whether to order dessert or say 'that's all'.

Now the same idea, in simple QA words

This surprises many people: the AI never calls the API itself. It only writes a request, like 'please run get_order_status for order A123'. The app reads that request, checks it, calls the real system using its own password/key, and gives the result back to the AI. Then the AI turns the result into a friendly answer. So the AI is the one who orders; the app is the waiter who actually goes to the kitchen.

How the story connects to the real thing

In the storyIn the AI system
You writing your order on a slipAI writing a tool request
The waiterYour application code
The kitchenThe real API / system
Food brought to your tableTool result given back to the AI
Deciding on dessertAI deciding the next step or final answer

Real-world example

A user asks a support bot 'Where is my order A123?'. Model output: tool_use → get_order_status({order_id: 'A123'}). The app calls GET /orders/A123 with its API key, receives {status: 'Out for delivery', eta: '6 PM'}, and passes it back. The model replies: 'Your order A123 is out for delivery and should arrive by 6 PM.'

Step by step, in plain words

  1. AI writes a tool request (tool name + details).
  2. The app checks the request is valid and allowed.
  3. The app calls the real system.
  4. The app gives the result back to the AI.
  5. The AI writes the final answer (or asks for another tool).

How a tester tests it

  • Validate arguments: wrong types, missing required fields, made-up IDs — does the app reject them before calling the API?
  • Mock the API to return errors, empty data, huge payloads — does the model explain honestly?
  • Check the final answer matches the tool result exactly (no invented ETA or amounts).
  • Security: confirm credentials never appear in the prompt or the model's output.

Try it yourself

1) Read the 'tool use' / 'function calling' page in any LLM provider's docs and find the JSON that the model returns. 2) Write the tool-result message your app would send back for a 'not found' order.

Interview angle

“Who actually calls the external API in function calling?”

The application, never the model. The model only proposes a call as structured output. That's why validation, authorisation, rate limits and audit logging live in the app layer — and why I test that layer separately with mocked tool results.