PHPackages                             adrenallen/ai-agents-laravel - 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. adrenallen/ai-agents-laravel

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

adrenallen/ai-agents-laravel
============================

A package to build AI Agents on top of Laravel

v6.0.2(1y ago)9688512[7 issues](https://github.com/adrenallen/ai-agents-laravel/issues)MITPHPPHP ^8.1

Since Jul 20Pushed 3mo ago5 watchersCompare

[ Source](https://github.com/adrenallen/ai-agents-laravel)[ Packagist](https://packagist.org/packages/adrenallen/ai-agents-laravel)[ RSS](/packages/adrenallen-ai-agents-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (21)Used By (0)

[You should use Laravel's official AI SDK now (click here)!](https://laravel.com/docs/12.x/ai-sdk)
==================================================================================================

[](#you-should-use-laravels-official-ai-sdk-now-click-here)

This project is no longer supported
-----------------------------------

[](#this-project-is-no-longer-supported)

[![](https://private-user-images.githubusercontent.com/9594539/422594123-54c1ecf7-b5b3-431f-80b1-d18bafa1a759.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQ4MzU3MTIsIm5iZiI6MTc3NDgzNTQxMiwicGF0aCI6Ii85NTk0NTM5LzQyMjU5NDEyMy01NGMxZWNmNy1iNWIzLTQzMWYtODBiMS1kMThiYWZhMWE3NTkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkY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ubusercontent.com/9b9e5e99668fd54a512c9c72e060c540405842edb65c8c0cfc0f036f952d1250/68747470733a2f2f706f7365722e707567782e6f72672f616472656e616c6c656e2f61692d6167656e74732d6c61726176656c2f76)](https://packagist.org/packages/adrenallen/ai-agents-laravel) [![Latest Unstable Version](https://camo.githubusercontent.com/33730c7b1e15415e219dfe1e1db1e92500001b05c0759ff405e5180b29411de9/68747470733a2f2f706f7365722e707567782e6f72672f616472656e616c6c656e2f61692d6167656e74732d6c61726176656c2f762f756e737461626c65)](https://packagist.org/packages/adrenallen/ai-agents-laravel) [![License](https://camo.githubusercontent.com/a6ef6d2b0d9e8eb2eb06fa7763d31931c009a1bb3ffda2bf60006c6adee08f01/68747470733a2f2f706f7365722e707567782e6f72672f616472656e616c6c656e2f61692d6167656e74732d6c61726176656c2f6c6963656e7365)](https://packagist.org/packages/adrenallen/ai-agents-laravel) [![PHP Version Require](https://camo.githubusercontent.com/ffd36ddeb05d7a8fe8128338be296e6a52a22067e823b8c6919495a4f6c56239/68747470733a2f2f706f7365722e707567782e6f72672f616472656e616c6c656e2f61692d6167656e74732d6c61726176656c2f726571756972652f706870)](https://packagist.org/packages/adrenallen/ai-agents-laravel)

Building with AI shouldn't be difficult, and AI Agents does its best to make it easy to build with AI inside of Laravel.

✍️ Spend more time writing code you care about, just provide comments and let the system take care of the rest!

📦 Agents are highly composable . Simply include the trait you need to give your AI the right capabilities for the job.

```
class TextingAgent extends BaseAgent {

    use \Adrenallen\AiAgentsLaravel\AgentTraits\SMSTrait; // Access to send SMS via Twilio, all handled automatically

    public string $prePrompt = "You are a helpful assistant";   // Pre-prompt
}
```

🔧 Need custom functionality or have an idea for a new AgentTrait? Create your own! Just follow the comment structure and the system will do the rest to ensure the AI understand and can use your functions!

```
/**
* @aiagent-description Adds two numbers together
* @param int $a
* @param int $b
* @return int
*/
public function add(int $a, int $b): int {
    return $a + $b;
}
```

🚀 Create a new AI Agent in &lt;20 lines of code!

Table of Contents
=================

[](#table-of-contents)

- [🔧 Setup](#-setup)
- [👨‍💻 Usage](#-usage)
    - [In Console/Testing](#in-consoletesting)
    - [In Code](#in-code)
- [🤖 Creating a new agent](#-creating-a-new-agent)
    - [Defining an agent function](#defining-an-agent-function)
- [🧰 Agent Traits](#-agent-traits)
- [📝 Chat Models](#-chat-models)
    - [Currently Supported](#currently-supported)
    - [Adding a new chat model](#adding-a-new-chat-model)
- [❤️ Contributing](#%EF%B8%8F-contributing)

🔧 Setup
-------

[](#-setup)

Install via composer

`composer require adrenallen/ai-agents-laravel`

You will need to publish the configuration files and fill out details based on the features you wish to use. You can publish the config files by running the following command:

`php artisan vendor:publish --provider="Adrenallen\AiAgentsLaravel\AiAgentsLaravelServiceProvider"`

👨‍💻 Usage
---------

[](#‍-usage)

### In Console/Testing

[](#in-consoletesting)

You can test chatting with an agent directly by using the provided artisan command

`php artisan ai:chat `

For example, to chat with the included `TestingAgent`

`php artisan ai:chat TestingAgent`

You can type `exit` to exit the chat.

### In Code

[](#in-code)

```
$chat = new \Adrenallen\AiAgentsLaravel\ChatModels\ChatGPT();
// or
$chat = new \Adrenallen\AiAgentsLaravel\ChatModels\AzureOpenAI();
// or
$chat = new \Adrenallen\AiAgentsLaravel\ChatModels\AnthropicClaude();

$agent = new \Adrenallen\AiAgentsLaravel\Agents\TestingAgent($chat); // Ensures the agent gets a pre-prompt at creation
$agent->ask("Hello, is this thing on?"); // Yes, I'm here. How can I assist you today?
$agent->lastCallMetadata;
/*
return $agent->lastCallMetadata;
= [
    "id" => "chatcmpl-8123ABC",
    "created" => 1705545737,
    "model" => "gpt-4",
    "systemFingerprint" => "fp_l33t123",
    "usage" => OpenAI\Responses\Chat\CreateResponseUsage {#5004
      +promptTokens: 365,
      +completionTokens: 17,
      +totalTokens: 382,
    },
  ]
*/
```

🤖 Creating a new agent
----------------------

[](#-creating-a-new-agent)

To create a new agent you will want to extend the `BaseAgent` class and define any additional functionality.

**NOTE: If you want to require your agent to always call a function, you can extend the `FunctionsAgent` instead!**

The `prePrompt` property is the pre-prompt that is passed to the chat model. This should describe how you want the agent to think and act.

You can use traits under `AgentTraits` to pull in specific functionality you may need.

i.e. if you want your agent to be able to send text messages, you could pull in the `SMSTrait` on your agent class. The bot will automatically know it is able to send text messages.

This is an example of an agent that can send text messages, do math, and get the weather.

**This is the total code required to create an agent.**

```
class TestingAgent extends BaseAgent {

    use \Adrenallen\AiAgentsLaravel\AgentTraits\SMSTrait; // Access to send SMS via Twilio
    use \Adrenallen\AiAgentsLaravel\AgentTraits\MathTrait; // Access to math functions
    use \Adrenallen\AiAgentsLaravel\AgentTraits\DateTrait;  // Access to date functions
    use \Adrenallen\AiAgentsLaravel\AgentTraits\WeatherTrait; // Access to openweathermap API

    public string $prePrompt = "You are a helpful assistant";   // Pre-prompt
}
```

### Defining an agent function

[](#defining-an-agent-function)

To define an agent function, you should follow php DocBlock to describe the params, return type, and method.

For the agent to have access to the function, you must include an additional PHPDoc block param called `@aiagent-description`. This must be a string that describes the function. Any functions that include that property in the agent's class will automatically be made available to the agent.

Example of the `add` function:

```
    /**
     * @param int $a
     * @param int $b
     * @return int
     * @aiagent-description Adds two numbers together
     */
    public function add(int $a, int $b): int {
        return $a + $b;
    }
```

🧰 Agent Traits
--------------

[](#-agent-traits)

Agent Traits can be used to plug and play functionality for an agent. Some are included in this package under the `AgentTraits` namespace.

`DateTrait` - Provides access to date functions (i.e. `compareDates` or `getCurrentDate`)

`MathTrait` - Provides access to math functions (i.e. `add` or `subtract`)

`SMSTrait` - Provides access to send SMS messages via Twilio (i.e. `sendSMS`)

`WeatherTrait` - Provides access to weather functions (i.e. `getWeather`)

`GeocodingTrait` - Provides access to geocoding functions (i.e. `getLatLongOfLocation`)

It is highly encouraged that you place re-usable functions in a trait, and then pull that trait into your agent.

📝 Chat Models
-------------

[](#-chat-models)

### Currently Supported

[](#currently-supported)

- GPT-3.5-turbo
- GPT-4
- Azure OpenAI
- Anthropic Claude

### Adding a new chat model

[](#adding-a-new-chat-model)

New models can be added by extending `AbstractChatModel`. This class provides the basic functionality required to interact with the chat model.

❤️ Contributing
---------------

[](#️-contributing)

Opening new issues is encouraged if you have any questions, issues, or ideas.

Pull requests are also welcome!

[See our contribution guide](CONTRIBUTING.md)

Star history
------------

[](#star-history)

[![Star History Chart](https://camo.githubusercontent.com/6937f1f056c2725cfc6049acd61531af5accca21fac877597074f3b645cf2ef8/68747470733a2f2f6170692e737461722d686973746f72792e636f6d2f7376673f7265706f733d616472656e616c6c656e2f61692d6167656e74732d6c61726176656c26747970653d44617465)](https://star-history.com/#adrenallen/ai-agents-laravel&Date)

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance63

Regular maintenance activity

Popularity33

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 97% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~36 days

Recently: every ~59 days

Total

17

Last Release

444d ago

Major Versions

v1.0.0 → v2.0.02023-07-24

v2.1.1 → v3.0.02023-10-15

v3.1.0 → v4.0.02024-02-20

v4.1.0 → v5.0.02024-03-15

v5.4.0 → v6.0.02024-07-09

PHP version history (2 changes)v1.0.0PHP ^7.4|^8.0

v4.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/571288bf305d3f72afc94b9e95737974f632653b3988e1a7047c9dc37cd35bb5?d=identicon)[garrett\_makes](/maintainers/garrett_makes)

---

Top Contributors

[![adrenallen](https://avatars.githubusercontent.com/u/9594539?v=4)](https://github.com/adrenallen "adrenallen (130 commits)")[![sorrell](https://avatars.githubusercontent.com/u/763445?v=4)](https://github.com/sorrell "sorrell (4 commits)")

---

Tags

agentsaiai-agents-frameworkanthropicchatgptclaudecomposerlaravelphplaravelaiChatGpt

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/adrenallen-ai-agents-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/adrenallen-ai-agents-laravel/health.svg)](https://phpackages.com/packages/adrenallen-ai-agents-laravel)
```

###  Alternatives

[maestroerror/laragent

Power of AI Agents in your Laravel project

630106.4k](/packages/maestroerror-laragent)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
