Skip to the workspace
Pebellslearn by building
Working with Model APIs  ›  Lesson

Function Calling and Tools

Function Calling 12 minWith function calling, the model asks for a described tool to be run with specific arguments, and the app decides whether to run it and returns the result for the model to use.

ai engineer / Function Calling and Tools

Explore each scene at your own pace.

01 · The rule

The rule

Function Calling and Tools

"Where is my order 4417?" is the most common question Pedal Point gets. The model cannot know the answer; it lives in the shop's order system, and changes by the hour. RAG helps with documents, but here the assistant needs to do something: look up a live record. That is function calling, also called tool use.

The rule

The model asks for a tool; your code decides and runs it.

You describe each tool to the model: a name, a plain-language description of when to use it, and a schema for its arguments.

{
  "name": "get_order_status",
  "description": "Look up the shipping status of one order by its number.",
  "parameters": {
    "type": "object",
    "properties": {"order_id": {"type": "string"}},
    "required": ["order_id"]
  }
}

When a question needs the tool, the model does not answer in words. It replies with a structured tool call: "call get_order_status with order_id = 4417". The model never runs anything itself. Your code runs the tool, sends back the result, and the model writes the final reply using it.

Some tasks need several tools in sequence. A common pattern, known as ReAct (reason and act), repeats a loop: the model thinks about what it needs, calls a tool, reads the result, and decides the next step, until it can answer. This loop is the heart of what people call AI agents.

Tool descriptions matter as much as prompts. A vague description ("gets data") leads to the wrong tool or wrong arguments. Keep the list short and each tool focused on one job. Every description is sent with each request, so twenty loosely named tools cost tokens and blur the choice, while three clear ones make it easy.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.