GetToolDefinitions
Returns tool definitions in JSON format for the specified custom functions, formatted for the specified model provider.
Format
GetToolDefinitions ( provider ; functionName {; functionName } )
Parameters
provider - a text expression for the model provider that the tool definitions are formatted for: OpenAI, Anthropic, Cohere, or Google. The value isn't case-sensitive.
functionName - a text expression for the name of a custom function defined in the current file. To get definitions for several custom functions, specify each name in a separate parameter.
Parameters in braces { } are optional.
Data type returned
text
Originated in version
26.1
Description
This function returns a JSON array that contains a tool definition for each custom function specified, formatted for the specified model provider. You can use the result in the Tool Definitions option of the Generate Response from Model script step. For background on tool definitions, see the "Tool definitions" section of that topic.
The function takes the following from the custom function's definition:
-
The function name, as the tool name.
-
The text in the Function description box of the Edit Custom Function dialog, as the tool description.
-
The parameter names, as the tool's parameter names.
-
The text in each Parameter description box, as the description of that parameter. See Using custom functions.
All parameters have the type string and are required.
For the specific JSON format used for tool definitions and tool calls, see the model provider's documentation—for example, Anthropic, Cohere, Google, and OpenAI.
Notes
-
This function returns "?" if
providerisn't a supported value. It also returns "?" if afunctionNamevalue isn't the name of a custom function in the current file. -
If a custom function or parameter has no description, the corresponding
descriptionvalue is an empty string. -
Some model providers don't allow certain characters in function names. As a best practice, limit the names of custom functions that you use as tools to A-Z, a-z, 0-9, _ (underscore), and - (hyphen).
Example 1
Gets the tool definition, in the format used by OpenAI, for a custom function named CityHasSalesOffice. The function has one parameter named city. The function and its parameter have descriptions in the Edit Custom Function dialog.
GetToolDefinitions ( "OpenAI" ; "CityHasSalesOffice" ) returns:
[
{
"function": {
"description": "Check whether our company has a sales office in a specified city. If it does, this function returns 'yes'; otherwise, it returns 'no'.",
"name": "CityHasSalesOffice",
"parameters": {
"additionalProperties": false,
"properties": {
"city": {
"description": "The name of a city",
"type": "string"
}
},
"required": [
"city"
],
"type": "object"
}
},
"type": "function"
}
]
Example 2
Gets the tool definitions for two custom functions: CityHasSalesOffice, from Example 1, and DistanceBetweenCities, which has two parameters named fromCity and toCity. The result contains one tool definition for each function, in the order of the functionName parameters.
GetToolDefinitions ( "OpenAI" ; "CityHasSalesOffice" ; "DistanceBetweenCities" ) returns:
[
{
"function": {
"description": "Check whether our company has a sales office in a specified city. If it does, this function returns 'yes'; otherwise, it returns 'no'.",
"name": "CityHasSalesOffice",
"parameters": {
"additionalProperties": false,
"properties": {
"city": {
"description": "The name of a city",
"type": "string"
}
},
"required": [
"city"
],
"type": "object"
}
},
"type": "function"
},
{
"function": {
"description": "Calculate the driving distance in kilometers between two cities.",
"name": "DistanceBetweenCities",
"parameters": {
"additionalProperties": false,
"properties": {
"fromCity": {
"description": "The name of the starting city",
"type": "string"
},
"toCity": {
"description": "The name of the destination city",
"type": "string"
}
},
"required": [
"fromCity",
"toCity"
],
"type": "object"
}
},
"type": "function"
}
]