百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

LarAgent

> 后端框架
开源

Laravel 项目中 AI 代理的功能

639 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

Laravel 项目中 AI 代理的功能

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, a Diamond-tier Laravel partner.

Website • Docs • Discord • Blog • AI Dev Sprint


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

LarAgent is officially powered by Redberry, one of the few Official Premier 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.


Documentation

Check out our full documentation to get started.

If you prefer article to get started, check it out: Laravel AI Agent Development Made Easy


Community & Support

Join our Discord community to ask questions, suggest features, or share what you're building.


Ecosystem

  • 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!


Table of Contents

  • Introduction
  • Features
  • Getting Started
    • Requirements
    • Installation
    • Configuration
  • Contributing
  • Getting Help
  • Testing
  • Security
  • Credits
  • License
  • ️ Roadmap

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?!

bash
php artisan make:agent YourAgentName

And it looks familiar, isn't it?

php
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

php
// ...
protected $history = \LarAgent\History\CacheChatHistory::class;
// ...

Or add temperature:

php
// ...
protected $temperature = 0.5;
// ...

Even disable parallel tool calls:

php
// ...
protected $parallelToolCalls = false;
// ...

Or configure multi-provider fallback for automatic failover:

php
// 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:

php
// ...
#[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:

php
Use App\AiAgents\YourAgentName;
// ...
YourAgentName::forUser(auth()->user())->respond($message);

Or use a custom name for the chat history:

php
Use App\AiAgents\YourAgentName;
// ...
YourAgentName::for("custom_history_name")->respond($message);

Let's find out more in documentation

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

Requirements

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

Installation

You can install the package via composer:

bash
composer require maestroerror/laragent

You can publish the config file with:

bash
php artisan vendor:publish --tag="laragent-config"

These are the contents of the published config file:

php
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

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:

…

Provider just gives you the defaults. Every config can be overridden per agent in agent class.

OpenAI Responses API

For newer OpenAI models that require the Responses API (e.g. models using reasoning_effort), use the OpenAiResponsesDriver:

php
    'openai_responses' => [
        'label' => 'openai_responses',
        'api_key' => env('OPENAI_API_KEY'),
        'driver' => \LarAgent\Drivers\OpenAi\OpenAiResponsesDriver::class,
        'default_truncation_threshold' => 50000,
        'default_max_completion_tokens' => 10000,
        'default_temperature' => 1,
    ],

You can then use reasoning_effort via the agent's $extras property:

php
class MyReasoningAgent extends Agent
{
    protected $provider = 'openai_responses';
    protected $model = 'gpt-5.4-mini';
    protected $extras = ['reasoning_effort' => 'high'];
}

For third-party providers offering a Responses-API-compatible endpoint, use OpenAiResponsesCompatible with an api_url.

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.

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

Getting Help

  • Open an issue for bugs or feature requests
  • Join discussions in existing issues
  • Join community server on Discord
  • Reach out to maintainers for guidance

Testing

bash
composer test

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

bash
./vendor/bin/pest testsManual

API key files looks like:

php
<?php

return 'YourApiKey';

Security

Please review our security policy on how to report security vulnerabilities.

Credits

Thanks to these people and projects, LarAgent would not be possible without them:

  • maestroerror
  • All Contributors
  • Redberry International
  • openai-php/client

License

The MIT License (MIT). Please see License File for more information.

Roadmap

Please see GitHub Projects for more information on the future development of LarAgent.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPaiai-agentsframeworklaravel

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架