genai.college · Learn · Leagues · Advertise

Prompt Engineering and API Integration · Lesson 6

Function Calling & Tool Integration

Function calling (tool use) lets a model ask your code to run something: look up weather, query a database, send an email. You describe each tool with a name, description and JSON schema of its inputs.

The loop: send the user message plus tool definitions → the model replies with a tool call and arguments → your code executes it → you send the result back → the model writes the final answer, or calls another tool.

The model never runs code itself. Your application decides what is allowed, validates arguments, and should require confirmation for risky actions such as payments or deletions.

Key points

tools = [{
  "name": "get_weather",
  "description": "Current weather for a city",
  "input_schema": {
    "type": "object",
    "properties": {"city": {"type": "string"}},
    "required": ["city"]
  }
}]

·

About · Contact · Privacy · Terms