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

Parameter Descriptions and Constraints

Document parameters with descriptions, enums, ranges, and other constraints to guide model input generation.

Parameter Descriptions and Constraints

You'll learn how to precisely describe function parameters with metadata like descriptions, enums, ranges, and other constraints so the LLM generates valid, appropriate inputs.

Why Descriptions and Constraints Matter

When you define a function schema for an LLM, the model uses your parameter descriptions to decide what values to send. A vague or missing description leads to bad guesses—like a librarian trying to file books without understanding the categories.

Think of it like this: If you tell someone to "pick a number," they might say "banana." But if you say "pick an integer between 1 and 100," they'll give you something useful.

Key Constraint Types

Descriptions

Every parameter should have a clear description field explaining what it represents and how to use it:

{
  "location": {
    "type": "string",
    "description": "City name or ZIP code, e.g., 'Seattle' or '98101'"
  }
}

Enums (Fixed Choices)

Restrict values to a predefined list:

{
  "unit": {
    "type": "string",
    "enum": ["celsius", "fahrenheit"],
    "description": "Temperature unit"
  }
}

Ranges and Patterns

Use JSON Schema constraints like minimum, maximum, minLength, pattern:

{
  "quantity": {
    "type": "integer",
    "minimum": 1,
    "maximum": 100,
    "description": "Number of items to order"
  }
}

The Payoff

Rich constraints guide the LLM toward valid inputs, reducing errors and eliminating the need for post-validation rejection loops. The model learns what's acceptable before making the call.

Key Takeaway: Well-documented parameters with enums, ranges, and clear descriptions act as guardrails, helping the LLM generate correct function arguments on the first try.