Function Schemas
Essential principles and best practices
Your Progress
0 / 5 completedKey Takeaways
🎯 Schema Essentials
1️⃣
Clear Naming
Use descriptive function names (get_weather, not func1)
2️⃣
Detailed Descriptions
Explain what the function does and when to use it
3️⃣
Type Everything
Specify types for all parameters (string, number, boolean, etc.)
4️⃣
Add Validation
Use constraints (min/max, patterns, enums) to ensure data quality
📋 Production-Ready Template
{
"name": "function_name",
"description": "Clear explanation of what this does",
"parameters": {
"type": "object",
"properties": {
"param1": {
"type": "string",
"description": "What this parameter is for",
"minLength": 1,
"maxLength": 100
},
"param2": {
"type": "number",
"description": "Numeric parameter",
"minimum": 0,
"maximum": 100
},
"param3": {
"type": "string",
"enum": ["option1", "option2", "option3"],
"description": "Choose from predefined options"
}
},
"required": ["param1"]
}
}⚠️ Common Mistakes
✗Vague function names like "tool1" or "helper"
✗Missing parameter descriptions
✗No type definitions for parameters
✗Forgetting to mark required parameters
✗Not using validation rules when needed
✗Overly complex nested structures
✅ Schema Design Checklist
✓Function name is clear and specific
✓Description explains when to use it
✓All parameters have types
✓Required fields are marked
✓Validation rules added where needed
✓Enums used for fixed choices
✓Examples provided in descriptions
✓Schema tested with real inputs
📚 Type Quick Reference
string
Text, IDs, URLs
number
Quantities, prices
boolean
True/false flags
array
Lists, collections
object
Nested structures
enum
Fixed choices
🎓 Further Learning
• JSON Schema Specification (json-schema.org)
• OpenAI Function Calling Documentation
• Anthropic Claude Tool Use Guide
• LangChain Tools Documentation
• Schema validation libraries (ajv, zod)