Tools allow you to give AI models access to external functions or data sources, enabling them to perform actions beyond simple text generation. You can define custom tools or use Latitude’s built-in tools.
Tool support depends on the specific AI provider and model. Check your
provider’s documentation for compatibility.
To make tools available to your prompt, list them under the tools key in the prompt’s configuration block (---).
Latitude provides several powerful built-in tools that you can enable directly:
latitude/search: Performs web searches to find up-to-date information.
latitude/code: Executes code snippets.
latitude/extract: Extracts structured data from text.
Simply include their names (e.g., latitude/search) in the tools list.
Learn more about using Latitude Tools.
For capabilities beyond the built-in tools, you can define your own custom tools. When the model decides to use a custom tool, Latitude will request its execution from your application via the SDK.
Define custom tools directly within the configuration block, outside the main tools list:
Each custom tool definition requires:
description: A clear explanation for the AI model of what the tool does.
parameters: A JSON Schema defining the expected input arguments for the tool.
When the AI model decides to use get_stock_price, the Latitude SDK in your application will receive a tool call request. Your code needs to:
- Execute the actual logic (e.g., call a financial API).
- Return the result back to Latitude.
Refer to the SDK documentation (TypeScript, Python) for details on handling tool calls.
JSON Schema for Parameters
Tool parameters must be defined using JSON Schema to specify their structure, types, and requirements. This helps the model understand how to call the tool correctly.
Key schema components:
type: object, string, number, integer, boolean, array.
description: Essential for explaining parameters to the model.
properties (for object type): Defines nested parameters.
required (for object type): Lists mandatory properties.
enum (for string, number): Specifies allowed values.
items (for array type): Defines the schema for array elements.
See the official JSON Schema guide for more details.
Example (Object with multiple parameters):
If you want to define a tool without parameters, for example a tool that generates a random number, you can omit the parameters key. However, providers such as Anthropic or Google, always requires parameters. In this case, the best option is to define an empty object as parameters:
Next Steps