Course contentsShow
← AI Engineering
Lesson 555 of 1,88614. Function Calling and Tool UseFree lesson

Function Schema Structure and OpenAI Format

Learn the JSON schema format for defining functions, including name, description, and parameters field structure.

Function Schema Structure and OpenAI Format

What you'll learn: How to properly structure the JSON schema that tells an LLM what functions are available and how to call them.

The Schema Blueprint

When you give an LLM access to functions, you're essentially handing it a manual: "Here are tools you can use, here's what they do, and here's how to use them correctly." That manual is written in a specific JSON format that OpenAI (and other providers) expect.

The Three Essential Fields

Every function schema needs three core components:

name — The function's identifier (like get_weather or search_database). Use snake_case and keep it descriptive but concise.

description — A plain-English explanation of what the function does and when to use it. This is critical—the LLM reads this to decide whether to call your function. Be specific: "Gets current weather for a given city" is better than "Weather function."

parameters — A JSON Schema object defining what inputs the function accepts. This follows the JSON Schema specification with type, properties, and required fields.

The Parameters Structure

The parameters field uses JSON Schema format:

"parameters": {
  "type": "object",
  "properties": {
    "city": {
      "type": "string",
      "description": "The city name, e.g. San Francisco"
    },
    "unit": {
      "type": "string",
      "enum": ["celsius", "fahrenheit"]
    }
  },
  "required": ["city"]
}

Each property gets its own type and description. The required array lists mandatory parameters. Use enum to restrict values to specific options.

Key Takeaway: Function schemas are structured JSON blueprints with name, description, and parameters fields that teach the LLM what tools it can use and how to use them correctly—think of it as writing API documentation specifically for AI consumption.