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 like42or3.14integer: Whole numbers only, like5or100boolean: True or false valuesarray: 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 adescriptionexplaining 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.