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

Complex Parameter Schemas with Nested Objects

Define nested object parameters and arrays of objects for functions requiring structured input data.

Complex Parameter Schemas with Nested Objects

What you'll learn: How to define function parameters with nested objects and arrays to handle sophisticated, structured input data in function calling.

The Core Idea

Sometimes a function needs more than just simple strings or numbers—it needs structured information. For example, imagine asking an AI to "schedule a meeting." You don't just need a date; you need attendees (with names and emails), a location (with room number and building), and preferences (virtual options, catering needs). These naturally group into nested structures.

In function calling, you describe these complex inputs using nested objects in your JSON schema. Think of it like Russian nesting dolls: one parameter contains another object, which might contain yet another object or an array of items.

How Nested Schemas Work

Instead of flat parameters like name and email, you create hierarchy:

{
    "type": "object",
    "properties": {
        "meeting": {
            "type": "object",
            "properties": {
                "title": {"type": "string"},
                "attendees": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "name": {"type": "string"},
                            "email": {"type": "string"}
                        }
                    }
                },
                "location": {
                    "type": "object",
                    "properties": {
                        "building": {"type": "string"},
                        "room": {"type": "number"}
                    }
                }
            },
            "required": ["title", "attendees"]
        }
    }
}

The LLM can now populate meeting.attendees[0].name or meeting.location.building precisely because you've defined the structure.

Why This Matters

Real-world functions often need rich context. Nested schemas let you organize related data logically, making your function signatures clearer and reducing ambiguity. The LLM understands the relationships between fields and generates properly structured JSON.

Key Takeaway: Nested object schemas let you define hierarchical, structured parameters—turning simple function calls into powerful interfaces for complex real-world operations.