Learn how function calling lets a model choose a tool, while the application safely executes the action.
Let's think about it this way for a second
You're not handing the model a database password and letting it act directly. The developer defines the tool name, description, and JSON schema, and the model submits a tool call. The application validates the arguments and checks permissions before it actually executes the function.

Let's connect this to everyday life
Give each tool a single responsibility and keep its parameters precise. Don't build one giant "manage_everything" tool. Separate read tools from write tools, and use confirmation or an idempotency key for write actions.
Let's try it hands-on together
const tools = [{
type: "function",
name: "get_weather",
description: "မြို့တစ်မြို့၏ လက်ရှိမိုးလေဝသကို ရယူရန်",
parameters: {
type: "object",
properties: { city: { type: "string" } },
required: ["city"],
additionalProperties: false,
},
strict: true,
}];You'll be able to define a read-only agent tool with a precise schema.5-minute try-it
Write a course search tool and a separate enrollment write tool. Add a rule requiring user confirmation before enrollment happens.
A quick word of caution
Don't treat AI output as the final word. Have a human review anything important — including code and user data — before it's actually used.
OpenAI — Function calling — OpenAI
OpenAI Agents SDK — OpenAI