PHPackages                             maestroerror/laragent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. maestroerror/laragent

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

maestroerror/laragent
=====================

Power of AI Agents in your Laravel project

1.3.0(1mo ago)630106.4k—2.7%56[2 PRs](https://github.com/MaestroError/LarAgent/pulls)MITPHPPHP ^8.3CI passing

Since Feb 15Pushed 2mo ago12 watchersCompare

[ Source](https://github.com/MaestroError/LarAgent)[ Packagist](https://packagist.org/packages/maestroerror/laragent)[ Docs](https://github.com/maestroerror/laragent)[ GitHub Sponsors](https://github.com/MaestroError)[ RSS](/packages/maestroerror-laragent/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (32)Versions (31)Used By (0)

LarAgent
========

[](#laragent)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a4aa7b6d3e8787b00c52924e53b2e7cbdb77dc4969fa76e3ba806ce2fce81fc6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61657374726f6572726f722f6c61726167656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maestroerror/laragent)[![GitHub Tests Action Status](https://camo.githubusercontent.com/0f937260bd536e124002b2ce463e9a87ee386ce34d62a8f63c9e443d9dcf032b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d61657374726f6572726f722f6c61726167656e742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/maestroerror/laragent/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/44aa795eb24d9435d9cb9d7ae9381cbae544a3ecbd25aa80d9f51e2b0d53d0ee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d61657374726f6572726f722f6c61726167656e742f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/maestroerror/laragent/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/8e2a2c95953d92bac3c8bc28d1ba634e45ebdfae5717f1d93d550bed0cab77ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61657374726f6572726f722f6c61726167656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maestroerror/laragent)

> "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](https://redberry.international?utm_source=github&utm_medium=github_laragent_readme&utm_campaign=AI+service+campaign), a Diamond-tier Laravel partner.

 [Website](https://laragent.ai) • [Docs](https://docs.laragent.ai) • [Discord](https://discord.gg/NAczq2T9F8) • [Blog](https://blog.laragent.ai) • [AI Dev Sprint](https://redberry.international/ai-agent-development/?utm_source=github&utm_medium=github_laragent_readme&utm_campaign=AI+service+campaign)

---

🚀 What is LarAgent?
-------------------

[](#-what-is-laragent)

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 &amp; 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

---

🧠 Backed by Redberry
--------------------

[](#-backed-by-redberry)

LarAgent is officially powered by [Redberry](https://redberry.international?utm_source=github&utm_medium=github_laragent_readme&utm_campaign=AI+service+campaign), 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](https://redberry.international/ai-agent-development/?utm_source=github&utm_medium=github_laragent_readme&utm_campaign=AI+service+campaign) about our 5-week PoC sprint for AI agent development.

---

📚 Documentation
---------------

[](#-documentation)

Check out our [full documentation](https://docs.laragent.ai/introduction) to get started.

**If you prefer article to get started, check it out: [Laravel AI Agent Development Made Easy](https://medium.com/towardsdev/laravel-ai-agent-development-made-easy-ac7ddd17a7d0)**

---

💬 Community &amp; Support
-------------------------

[](#-community--support)

Join our [Discord community](https://discord.gg/NAczq2T9F8) to ask questions, suggest features, or share what you're building.

---

🧩 Ecosystem
-----------

[](#-ecosystem)

- [MCP Client](https://github.com/RedberryProducts/mcp-client-laravel) – a modular client for managing tools and resources from MCP servers

You can find tutorials here:

- LarAgent Blog - [Tutorials](https://blog.laragent.ai/tag/tutorials/)

---

> Each GitHub ⭐️ helps the community grow. Thanks for the support!

Any questions? Join our [Discord](https://discord.gg/NAczq2T9F8) server!

---

Table of Contents
-----------------

[](#table-of-contents)

- [📖 Introduction](#introduction)
- [🎉 Features](#features)
- [🚀 Getting Started](#getting-started)
    - [Requirements](#requirements)
    - [Installation](#installation)
    - [Configuration](#configuration)
- [🤝 Contributing](#contributing)
- [🤝 Getting Help](#getting-help)
- [🧪 Testing](#testing)
- [🔒 Security](#security)
- [🙌 Credits](#credits)
- [📜 License](#license)
- [🛣️ Roadmap](#roadmap)

Introduction
------------

[](#introduction)

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 YourAgentName
```

And 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;
// ...
```

Or configure multi-provider fallback for automatic failover:

```
// Simple array of providers (first is primary, others are fallbacks in order)
protected $provider = ['default', 'gemini', 'claude'];

// With per-provider config overrides
protected $provider = [
    'default',
    'gemini' => ['model' => 'gemini-2.0-flash'],
    'claude',
];
```

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](https://docs.laragent.ai/) 👍

Features
--------

[](#features)

- 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)
    - `Tool` facade 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)
- Multi-provider fallback with automatic failover
- Support for both Laravel and standalone usage

Getting Started
---------------

[](#getting-started)

### Requirements

[](#requirements)

- Laravel 10.x or higher
- PHP 8.3 or higher

### Installation

[](#installation)

You can install the package via composer:

```
composer require maestroerror/laragent
```

You 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,
        ],
    ],
];
```

### Configuration

[](#configuration)

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.

Contributing
------------

[](#contributing)

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](https://docs.laragent.ai/development).

We aim to review all pull requests within a 2 weeks. Thank you for contributing to LarAgent!

Getting Help
------------

[](#getting-help)

- Open an issue for bugs or feature requests
- Join discussions in existing issues
- Join community server on [Discord](https://discord.gg/NAczq2T9F8)
- Reach out to maintainers for guidance

Testing
-------

[](#testing)

```
composer test
```

To run manual tests create files in `testsManual\.gitignore` with API keys and run:

```
./vendor/bin/pest testsManual
```

API key files looks like:

```
