OutputMode::Tools, which is the default mode. For most applications, this is an implementation detail — you define a response model and read the result.
However, the FunctionCall addon takes this concept further by letting you extract arguments for real PHP functions, methods, or closures directly from natural language. This is particularly useful when building tool-use capabilities for AI chatbots or agents.
Extracting Arguments for a Function
TheFunctionCallFactory inspects a function’s signature via reflection and builds a response model that matches its parameters. The LLM then extracts the correct argument values from the input text.
Extracting Arguments for a Method
You can also extract arguments for class methods by specifying both the class and method name.Extracting Arguments for a Callable
Closures and other callables work the same way.How It Works
Under the hood,FunctionCallFactory uses CallableSchemaFactory to reflect on the callable’s parameters and produce a Schema object. That schema is then wrapped in a Structure that Instructor can use as a response model. The LLM receives a JSON Schema derived from the function signature (including parameter names, types, and docblock descriptions) and returns matching values.
Output Modes
By default, Instructor usesOutputMode::Tools (tool-calling). You only need to change the mode when a specific provider or workflow requires JSON output instead of tool-calling. The function call extraction works with any output mode.