Function Calling
ELI5 — The Vibe Check
Function Calling is the OpenAI term for what Anthropic calls Tool Use — teaching the AI to call your code functions. You tell the AI 'here are functions you can use' with their names and parameters, and the AI decides which to call and with what arguments. Your code executes the function and tells the AI the result. It's AI and your code collaborating.
Real Talk
Function calling is the mechanism by which LLMs generate structured JSON specifying a function name and arguments for the host application to execute. The model determines when and how to call a function based on the user's request and the function's description. Results are fed back to the model as tool results. Standardized across OpenAI, Anthropic, Google, and others.
Show Me The Code
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "What's the weather in Paris?"}],
functions=[{
"name": "get_weather",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}]
)
When You'll Hear This
"Use function calling to let the AI query the database." / "Function calling is OpenAI's name for tool use."
Related Terms
Agent
An AI agent is an LLM that doesn't just answer questions — it takes actions.
API Key
An API key is your password to use an AI service. You include it in every request to prove you're allowed to use the API and so they know who to charge.
LLM (Large Language Model)
An LLM is a humongous AI that read basically the entire internet and learned to predict what words come next, really really well.
MCP (Model Context Protocol)
MCP is like USB for AI — a universal standard for connecting AI models to external tools and data.
Tool Use
Tool use is when an AI can call external functions, APIs, or programs to do things it can't do alone.