The Laravel AI SDK offers powerful capabilities for building intelligent applications. To further enhance this, Ship Fast Labs, under the direction of Pushpak Chhajed, has introduced "Toolkit," a community catalog of reusable AI tools. This initiative provides developers with a streamlined way to integrate diverse AI functionalities into their Laravel projects.
Modular and Independent Tools
Toolkit emphasizes a modular approach, with each tool packaged as a separate Composer dependency. This design ensures that developers only install the specific tools required by their AI agents, avoiding unnecessary overhead. There's no shared core, no service provider registration, and no published configuration files. Each tool is a class that implements Laravel\Ai\Contracts\Tool, defining a description(), a handle(), and a schema() method.
Installation is straightforward:
composer require shipfastlabs/toolkit-calculator
composer require shipfastlabs/toolkit-database
Once installed, tools are instantiated and passed to an agent's tools() method:
use Shipfastlabs\Toolkit\Calculator\CalculatorTool;
use Shipfastlabs\Toolkit\Database\DatabaseQueryTool;
$tools = [
new CalculatorTool,
new DatabaseQueryTool,
];
The description() method advertises the tool's purpose, while schema() defines its expected inputs. This allows the AI model to intelligently decide when and how to invoke a tool. Importantly, results, including errors, are returned as strings, enabling the model to interpret failures and attempt recovery.
Featured Tools
Calculator Without eval()
The Calculator tool processes mathematical expressions using a recursive-descent parser, avoiding PHP's eval() for enhanced security. It supports standard arithmetic operations (+, -, *, /, %), exponentiation (^), parentheses, unary signs, and decimals. Invalid inputs or errors like division by zero are gracefully handled, returning informative strings to the model.
Read-Only Database Queries
For secure data retrieval, the Database tool executes single SQL SELECT statements, returning results as pretty-printed JSON. It incorporates robust guardrails:
- Only
SELECTstatements (includingWITH … SELECTCTEs) are permitted. INSERT,UPDATE,DELETE,DROP,ALTER, and similar keywords are strictly rejected.- Queries containing
;separators are disallowed. - A
LIMITclause is automatically appended if missing.
This tool can be configured within config/ai.php:
// config/ai.php
'toolkit' => [
'database' => [
'connection' => env('TOOLKIT_DATABASE_CONNECTION'),
'max_rows' => (int) env('TOOLKIT_DATABASE_MAX_ROWS', 100),
],
],
This allows specifying a read-only database connection and capping the number of returned rows for added security and performance.
Web Search and Research Providers
Toolkit integrates with several prominent search and research APIs, offering helper functions to register entire sets of tools or individual classes:
- Exa (
toolkit-exa): ProvidesExaSearch,ExaFindSimilar,ExaGetContents, andExaAnswerfor embeddings-based web search, similarity lookups, content extraction, and cited answers. - Perplexity (
toolkit-perplexity): OffersPerplexitySearchfor ranked sources andPerplexityAskfor cited answers across Sonar models, supportingweb,academic, andsecsearch modes. - Tavily (
toolkit-tavily): IncludesTavilySearch,TavilyExtract,TavilyCrawl, andTavilyMapfor search, content extraction, site crawling, and site mapping.
API keys are managed via Laravel's services configuration, and optional defaults can be set in ai.toolkit.*. The tools handle API errors by returning strings, preventing application crashes.
JigsawStack's Endpoint Library
The JigsawStack package (toolkit-jigsawstack) exposes a tool for each endpoint, categorized into general, translation, web, vision, audio, and validation services. This covers a wide array of functionalities, from sentiment analysis and text-to-SQL to image translation and object detection. Each tool returns the raw JSON response, allowing the model to process all available data. Requests time out after 60 seconds, and clear messages are provided for missing API keys.
Installation and Configuration
To use Toolkit, simply require the desired packages via Composer. For remote API tools, ensure the corresponding provider key is configured in config/services.php and its .env entry. Detailed configuration instructions are available on each tool's documentation page.
Key Takeaways
- Toolkit offers a modular collection of reusable AI tools for the Laravel AI SDK.
- Each tool is an independent Composer package, minimizing dependencies.
- Tools implement
Laravel\Ai\Contracts\Toolwithdescription(),handle(), andschema()methods. - Includes secure Calculator, read-only Database query, and integrations with Exa, Perplexity, Tavily, and JigsawStack APIs.
- Configuration is integrated with Laravel's existing
config/ai.phpandconfig/services.php.
Explore the full catalog on the Toolkit website and view the source code on GitHub.