Download the PHP package alidaaer/laravel-ai-agent without Composer
On this page you can find all versions of the php package alidaaer/laravel-ai-agent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alidaaer/laravel-ai-agent
More information about alidaaer/laravel-ai-agent
Files in alidaaer/laravel-ai-agent
Package laravel-ai-agent
Short Description Give your Laravel app a brain, safely. Build AI Agents that can execute real actions in your application.
License MIT
Homepage https://github.com/alidaaer/laravel-ai-agent
Informations about the package laravel-ai-agent
Laravel AI Agent
🧠 Give your Laravel app a brain, safely.
Build AI Agents that execute real actions in your Laravel application with minimal code.
Laravel AI Agent is the ultimate Laravel AI package for building intelligent automation. Transform your Laravel app with AI-powered agents that can understand natural language and execute PHP methods directly. Perfect for Laravel GPT integration, AI automation, and function calling. This Laravel AI solution works with OpenAI, Anthropic Claude, Gemini, and more - making it the most flexible AI assistant for Laravel.
✨ Why Laravel AI Agent?
| Feature | Description |
|---|---|
| 🚀 Zero Boilerplate | Turn any method into an AI tool with a single attribute |
| 🧠 Smart Auto-Inference | Auto-generates descriptions and infers types from parameter names |
| 💬 Chat Widget | Beautiful, customizable Web Component - just drop it in! |
| 🔌 Multi-Provider | OpenAI, Anthropic Claude, Google Gemini, DeepSeek, OpenRouter |
| 💾 Memory | AI-powered summarization with smart pointer tracking — session or database |
| 📊 Markdown Responses | Tables, formatting, and rich text in chat |
| ⚡ Smart Returns | view(), redirect(), Model — AI understands them all |
| 🤖 Multi-Agent | Class-based agents with per-method access control |
| 🛡️ Security Built-in | Prompt injection detection, XSS prevention, secret redaction |
| 🎯 Laravel Native | Feels like part of the framework |
📦 Installation
Add to your .env:
Run migrations for conversation history:
🚀 Quick Start
1. Add the Chat Widget ⚡
Drop it into any Blade view — routes are auto-registered!
Open the page, click the bubble, start talking. You already have a working AI chatbot! 🎉
All widget settings (theme, language, position, etc.) are read from config/ai-agent.php:
💡 The
system_promptis set in config (not HTML) so it stays hidden from the client.
2. Give AI Your Tools (Zero-Config!)
Place it anywhere in app/ — the package auto-discovers all #[AsAITool] methods. Now say "Add a product called iPhone for $999" and it actually does it! 🚀
🤖 Need custom agents? Create dedicated agents with
php artisan make:agent— see Multi-Agent System.
💬 Chat Widget Component
A beautiful, drop-in Web Component for AI chat — with conversations, i18n, and stop button built-in.
Full-Featured Example
Or use the PHP helper directly with overrides:
All Options
| Attribute | Description | Default |
|---|---|---|
endpoint |
Chat API URL | Required |
stream |
Enable SSE streaming (boolean) | — |
history-endpoint |
Load conversation history + conversations sidebar | — |
persist-messages |
Keep messages across page reloads (boolean) | — |
theme |
light or dark |
dark |
lang |
Language: en, ar, fr, es, zh |
en |
rtl |
Right-to-left mode (boolean) | Auto for ar |
title |
Header title | AI Assistant |
subtitle |
Header subtitle | — |
welcome-message |
First bot message | — |
placeholder |
Input placeholder | Type your message... |
primary-color |
Theme color | #6366f1 |
position |
bottom-right, bottom-left, top-right, top-left |
bottom-right |
width |
Widget width | 400px |
height |
Widget height | 600px |
button-icon |
Floating button icon (URL or emoji) | 💬 |
button-size |
Floating button size | 56px |
Features
- ✅ SSE Streaming — Real-time streaming with tool execution progress
- ✅ Markdown Support — Tables, bold, code blocks with copy button, lists
- ✅ Voice Input — Built-in Web Speech API microphone button
- ✅ i18n — 5 languages built-in (EN, AR, FR, ES, ZH)
- ✅ RTL Support — Auto-detected for Arabic, Hebrew, Farsi
- ✅ Stop Button — Cancel AI responses mid-generation
- ✅ Conversations Sidebar — Switch between past conversations (isolated per agent)
- ✅ Keyboard Shortcuts — Escape to close, Enter to send, Shift+Enter for new line
- ✅ Mobile Responsive — Full-screen on mobile
- ✅ No Dependencies — Pure Web Component
🔧 Chat API
Routes are auto-registered — no setup needed! The widget works out of the box with:
Need a custom endpoint? Easy:
🛠️ Creating Tools
Zero-Config (Recommended)
With Custom Description
With Custom Parameters
The package auto-discovers parameters from type hints. But if your method uses Request or you want more control, define them manually with name:type syntax:
Supported types: string, integer, number, boolean, array. Without :type, the type is inferred from the parameter name (id → integer, price → number).
💡 When to use
params? Only when auto-discovery isn't enough — e.g., dynamicRequestinputs, or when you want custom descriptions for the AI.
Smart Type Inference
No type hints? We infer from names:
| Parameter Name | Inferred Type |
|---|---|
$id, $productId, $userId |
integer |
$price, $total, $amount |
number |
$isActive, $hasItems, $enabled |
boolean |
$items, $products, $users |
array |
| Other | string |
⚡ Smart Return Handling
Use your existing methods as AI tools — no refactoring needed.
The agent automatically understands any return type: view(), redirect(), Model, Collection, JsonResponse, and even catches exceptions and validation errors gracefully.
Zero-Config — It Just Works
Exceptions & Validation — Handled Automatically
isAICall() — Full Control When You Need It
Customize responses for AI vs Web with a single helper:
One method, two audiences. Web users get a Blade view, AI gets structured data.
| Return Type | What AI Receives |
|---|---|
view('...', $data) |
The $data variables directly |
redirect()->with('message', '...') |
{"message": "..."} |
Eloquent Model |
model->toArray() |
Collection |
collection->toArray() |
JsonResponse |
The JSON data |
ValidationException |
Error messages in user's language |
Any Exception |
Error message for AI to report |
🔌 Providers
🤖 Multi-Agent System
Create dedicated agent classes with isolated tools, permissions, and conversations.
1. Create an Agent
This generates a class in app/AI/Agents/ and auto-registers it in config/ai-agent.php.
2. Scope Tools Per Agent
Use class references for IDE autocompletion and refactor safety:
Rule: No agents param = available to all agents. Explicit list = restricted.
3. Auto-Generated Endpoints
Each agent gets its own isolated routes — automatically:
Conversations are isolated per agent — each agent sees only its own conversation history.
4. Add Widget to Blade
Each agent renders its own fully-configured widget:
Each widget automatically uses the correct endpoints, theme, language, and position defined in the agent's widgetConfig().
5. Customize Widget Appearance
6. Mobile / API Usage
No agents? Everything works without agents — use the generic
/ai-agent/chatendpoint with the widget directly.
💾 Conversation Memory
Smart Memory Management:
- After every
summarize_aftermessages, the AI generates a concise summary of older messages - Messages are never deleted until reaching
max_messageshard limit - The LLM receives:
[summary of old context]+[last N recent messages]+[new message] - Falls back to manual summarization if AI summarization fails
- Disable AI summarization with
AI_AGENT_AI_SUMMARY=falsein.env
⚙️ Configuration
📖 See Full Documentation for all configuration options.
📡 Events
📖 Full Example
That's it. Tools are auto-discovered, routes are auto-registered, conversations are isolated per agent, memory is auto-managed. 🎉
📖 Documentation
For the full detailed documentation — including all configuration options, security features, event system, streaming, and more — see documentation.md.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
The MIT License (MIT). See License File for more information.
Made with ❤️ for Laravel developers
All versions of laravel-ai-agent with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/validation Version ^10.0|^11.0|^12.0
illuminate/cache Version ^10.0|^11.0|^12.0