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

Parameter Types and Required vs Optional Fields

Define parameter types (string, number, boolean, array, object) and specify which parameters are required.

Parameter Types and Required vs Optional Fields

You'll learn: How to define the exact shape and rules for function parameters so LLMs know what data to provide—and what they can skip.

Understanding Parameter Types

When you describe a function to an LLM, you need to specify what type each parameter accepts. Think of types as categories that tell the model "this slot needs a number" or "this slot needs text."

The common types match JSON Schema standards:

  • string: Text like "New York" or "user@example.com"
  • number: Numeric values like 42 or 3.14
  • integer: Whole numbers only, like 5 or 100
  • boolean: True or false values
  • array: A list of items, like ["apple", "banana", "cherry"]
  • object: Nested data structures with their own properties

Each type helps the LLM understand what kind of data to extract from user input and format correctly.

Required vs Optional Fields

Not every parameter is mandatory. You control this with the required array in your function schema:

  • Required fields: Must be provided for the function call to succeed. List these in the "required" array.
  • Optional fields: Can be omitted. Omit them from the "required" array and provide a description explaining when they're used.

Think of ordering coffee: "size" is required, but "extra shot" is optional. The LLM needs to know which parameters it must fill versus which are nice-to-have.

When parameters are optional, the LLM can call your function even with incomplete information, making interactions more flexible and natural.

Key Takeaway: Defining precise parameter types (string, number, boolean, etc.) and marking fields as required or optional ensures the LLM provides correctly-shaped data and knows when it has enough information to act.