LLM Application Development
Intermediate
4.5
Function Calling: Let an LLM Use Your Tools
Connect a model to real functions so it can fetch data and take actions.
1h 35m
1 lesson
1.2K students
What You'll Learn
Learning objectives will be added soon.
Tutorial Content
The idea
Function calling lets you describe tools (as JSON schemas) to the model. Instead of answering directly, the model can return a structured request to call one of your functions — you run it and feed the result back.
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {"type": "object",
"properties": {"city": {"type": "string"}}, "required": ["city"]},
},
}]
resp = client.chat.completions.create(model="gpt-4o-mini",
messages=[{"role":"user","content":"Weather in Paris?"}], tools=tools)The loop
Call the model → if it requests a tool, run it → append the result as a tool message → call again. This loop is the foundation of every AI agent.
Your Progress
Sign in to track your progress
Tags
LLM
API
Agents