"The easiest way to create and maintain AI agents in your Laravel projects."
LarAgent is an AI agent development framework for Laravel
Officially powered by Redberry, a Diamond-tier Laravel partner.
Website β’ Docs β’ Discord β’ Blog β’ AI Dev Sprint
LarAgent is an open-source framework that lets you create powerful AI agents in Laravel with minimal configuration and maximum extensibility.
LarAgent brings Laravel-grade productivity to AI agent development. Thatβs why Laravel + LarAgent is the most productive stack out there for building AI agents.
Whether you're looking to automate internal operations or build conversational experiences for your product, LarAgent offers developer-first tools:
- Eloquent-style API for building real AI agents - define agents, tools, memories, and workflows
- First-class tooling system with MCP server support
- Pluggable memory & context management
- Multi-agent workflows with queues, chainable tasks, and reasoning
- Structured output for reliability and seamless integration
- Multi-modal input and modular provider support
- Extensive Event system for effortless customization and observability
- Built-in API exposure via OpenAI-compatible schema
LarAgent is officially powered by Redberry, one of only 10 Diamond-tier Laravel partners worldwide. This partnership ensures the continued evolution of LarAgent with increased engineering support, better documentation, and a growing ecosystem of AI-first Laravel tools.
Need help with building your AI agent? Talk to us about our 5-week PoC sprint for AI agent development.
Check out our full documentation to get started.
If you prefer article to get started, check it out: Laravel AI Agent Development Made Easy
Join our Discord community to ask questions, suggest features, or share what you're building.
- MCP Client β a modular client for managing tools and resources from MCP servers
You can find tutorials here:
- LarAgent Blog - Tutorials
Each GitHub βοΈ helps the community grow. Thanks for the support!
Any questions? Join our Discord server!
- π Introduction
- π Features
- π Getting Started
- π€ Contributing
- π€ Getting Help
- π§ͺ Testing
- π Security
- π Credits
- π License
- π£οΈ Roadmap
LarAgent brings the power of AI agents to your Laravel projects with an elegant syntax. Create, extend, and manage AI agents with ease while maintaining Laravel's fluent API design patterns.
What if you can create AI agents just like you create any other Eloquent model?
Why not?! π
php artisan make:agent YourAgentNameAnd it looks familiar, isn't it?
namespace App\AiAgents;
use LarAgent\Agent;
class YourAgentName extends Agent
{
protected $model = 'gpt-4';
protected $history = 'in_memory';
protected $provider = 'default';
protected $tools = [];
public function instructions()
{
return "Define your agent's instructions here.";
}
public function prompt($message)
{
return $message;
}
}And you can tweak the configs, like history
// ...
protected $history = \LarAgent\History\CacheChatHistory::class;
// ...Or add temperature:
// ...
protected $temperature = 0.5;
// ...Even disable parallel tool calls:
// ...
protected $parallelToolCalls = false;
// ...Oh, and add a new tool as well:
// ...
#[Tool('Get the current weather in a given location')]
public function exampleWeatherTool($location, $unit = 'celsius')
{
return 'The weather in '.$location.' is '.'20'.' degrees '.$unit;
}
// ...And run it, per user:
Use App\AiAgents\YourAgentName;
// ...
YourAgentName::forUser(auth()->user())->respond($message);Or use a custom name for the chat history:
Use App\AiAgents\YourAgentName;
// ...
YourAgentName::for("custom_history_name")->respond($message);Let's find out more in documentation π
- Eloquent-like syntax for creating and managing AI agents
- Laravel-style artisan commands
- Flexible agent configuration (model, temperature, context window, etc.)
- Structured output handling
- Image input support
- Easily extendable, including chat histories and LLM drivers
- Multiple built-in chat history storage options (in-memory, cache, json, etc.)
- Per-user chat history management
- Custom chat history naming support
- Custom tool creation with attribute-based configuration
- Tools via classes
- Tools via methods of AI agent class (Auto)
Toolfacade for shortened tool creation- Parallel tool execution capability (can be disabled)
- Extensive Event system for agent interactions (Nearly everything is hookable)
- Multiple provider support (Can be set per model)
- Support for both Laravel and standalone usage
- Laravel 10.x or higher
- PHP 8.3 or higher
You can install the package via composer:
composer require maestroerror/laragentYou can publish the config file with:
php artisan vendor:publish --tag="laragent-config"These are the contents of the published config file:
return [
'default_driver' => \LarAgent\Drivers\OpenAi\OpenAiDriver::class,
'default_chat_history' => \LarAgent\History\InMemoryChatHistory::class,
'providers' => [
'default' => [
'label' => 'openai',
'api_key' => env('OPENAI_API_KEY'),
'default_truncation_threshold' => 50000,
'default_max_completion_tokens' => 100,
'default_temperature' => 1,
],
],
];You can configure the package by editing the config/laragent.php file. Here is an example of custom provider with all possible configurations you can apply:
// Example custom provider with all possible configurations
'custom_provider' => [
// Just name for reference, changes nothing
'label' => 'mini',
'model' => 'gpt-3.5-turbo',
'api_key' => env('CUSTOM_API_KEY'),
'api_url' => env('CUSTOM_API_URL'),
// Default driver and chat history
'driver' => \LarAgent\Drivers\OpenAi\OpenAiDriver::class,
'chat_history' => \LarAgent\History\InMemoryChatHistory::class,
'default_truncation_threshold' => 15000,
'default_max_completion_tokens' => 100,
'default_temperature' => 1,
// Enable/disable parallel tool calls
'parallel_tool_calls' => true,
// Store metadata with messages
'store_meta' => true,
// Save chat keys to memory via chatHistory
'save_chat_keys' => true,
],Provider just gives you the defaults. Every config can be overridden per agent in agent class.
We welcome contributions to LarAgent! Whether it's improving documentation, fixing bugs, or adding new features, your help is appreciated. Here's how you can contribute.
We aim to review all pull requests within a 2 weeks. Thank you for contributing to LarAgent!
- Open an issue for bugs or feature requests
- Join discussions in existing issues
- Join community server on Discord
- Reach out to maintainers for guidance
composer testTo run manual tests create files in testsManual\.gitignore with API keys and run:
./vendor/bin/pest testsManualAPI key files looks like:
<?php
return 'YourApiKey';Please review our security policy on how to report security vulnerabilities.
Thanks to these people and projects, LarAgent would not be possible without them:
The MIT License (MIT). Please see License File for more information.
Please see GitHub Projects for more information on the future development of LarAgent.