RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /Function Calling for Local Models
  6. /Ch. 2
Function Calling for Local Models

02. JSON Schema for Tools

Chapter 2 of 18 · 15 min
KEY INSIGHT

Schema descriptions guide model decisions—invest time writing clear, specific descriptions for parameters that could be confused.

JSON Schema defines the structure that tool definitions must follow to enable reliable function calling. Each tool requires a name, description, and parameter specification matching the JSON Schema draft-07 format that most models expect.

A tool definition contains several required fields. The type field must be "object" since every function call is a JSON object. The properties object defines available parameters, where each parameter name maps to its type and description. The required array lists which parameters must be present in every call. Additional fields like description at the top level explain what the function does to help the model decide when to call it.

Consider a weather lookup tool with city and units parameters:

{
  "type": "object",
  "properties": {
    "city": {
      "type": "string",
      "description": "City name for weather lookup"
    },
    "units": {
      "type": "string",
      "enum": ["celsius", "fahrenheit"],
      "description": "Temperature unit preference"
    }
  },
  "required": ["city"]
}

The description fields are critical—models use them to decide which tool fits a user request and how to format arguments. Descriptions should be specific enough to disambiguate similar tools but concise enough to fit in context windows.

Complex parameter types require nested schema definitions. An array parameter uses type: "array" with an items sub-schema defining element types. Optional parameters simply omit them from the required array. Default values cannot be specified in JSON Schema alone; document them in descriptions and handle them in your execution code.

Nested objects work similarly:

{
  "type": "object",
  "properties": {
    "location": {
      "type": "object",
      "properties": {
        "latitude": {"type": "number"},
        "longitude": {"type": "number"}
      },
      "required": ["latitude", "longitude"]
    },
    "radius_km": {"type": "number"}
  },
  "required": ["location"]
}

Validation failures occur when models produce invalid arguments. Your client code must validate calls against the schema before execution, rejecting malformed calls and returning error messages that help the model retry correctly.

EXERCISE

Define a JSON Schema for a file search tool with parameters for path, pattern (regex), and max_results. Write descriptions that help the model understand when to use regex vs simple text matching.

← Chapter 1
Function Calling Overview
Chapter 3 →
Defining Tool Functions