Laravel Cloud is here! Zero-config managed infrastructure for Laravel apps. Deploy now.

The Laravel Way to Build AI Agents That Actually Work

Published on by

The Laravel Way to Build AI Agents That Actually Work image

After integrating AI into dozens of Laravel applications, a pattern emerges: teams spend 20% of their time making AI work and 80% making sure it doesn't break. Every project reinvents the same wheels – session management, tool calling, prompt testing, error handling.

There's now a better way.

Vizra ADK brings software engineering principles to AI development in Laravel. Not just another API wrapper, but a complete framework for building, testing, and deploying intelligent agents that teams can actually trust in production.

Think Laravel's elegance meets AI's power. Controllers for agents. Migrations for memory. Tests for prompts. Everything developers love about Laravel, now for AI.

Free, open source, and built the Laravel way.

From Zero to AI Agent in Under 2 Minutes

Let's build something real. Fire up your terminal:

composer require vizra/vizra-adk
php artisan vizra:install

Add your AI provider key to .env:

OPENAI_API_KEY=your-key-here
# Also supports Anthropic, Google Gemini + many more

Now create your first agent:

php artisan vizra:make:agent CustomerSupportAgent

That's it! You've just created an intelligent AI assistant. Let's make it useful:

<?php
 
namespace App\Agents;
 
use Vizra\VizraADK\Agents\BaseLlmAgent;
 
class CustomerSupportAgent extends BaseLlmAgent
{
protected string $name = 'customer_support';
 
protected string $description = 'Handles customer inquiries with empathy and efficiency';
 
protected string $instructions = "You are a helpful customer support agent for AcmeStore.
 
Key information:
- We sell electronics and gadgets
- Free shipping on orders over $50
- 30-day return policy
- Business hours: 9 AM - 6 PM EST
 
Be friendly, professional, and solution-oriented.";
 
protected string $model = 'gpt-3.5-turbo';
}

Test Your Agent Instantly!

Want to see your agent in action? You have three ways to test it immediately:

# 1. Command line chat
php artisan vizra:chat customer_support
 
# 2. Beautiful web dashboard (with trace debugging!)
# Visit: http://your-app.test/vizra
 
# 3. Built-in API endpoints (no controller needed!)
curl -X POST http://your-app.test/api/vizra-adk/interact \
-H "Content-Type: application/json" \
-d '{"agent_name": "customer_support", "input": "Hello!"}'

That's right – Vizra ADK includes ready-to-use API endpoints. No need to write controllers unless you want custom logic.

Of course, if you prefer the traditional approach:

// In your controller (optional)
use App\Agents\CustomerSupportAgent;
 
public function chat(Request $request)
{
$response = CustomerSupportAgent::run($request->input('message'))
->forUser(auth()->user())
->go();
 
return response()->json(['reply' => $response]);
}

Your agent automatically maintains conversation history per user. No session management headaches.

Give Your Agents Superpowers with Tools

Here's where it gets exciting. Your agents can actually do things, not just chat:

php artisan vizra:make:tool OrderLookupTool
<?php
 
namespace App\Tools;
 
use Vizra\VizraADK\Contracts\ToolInterface;
use Vizra\VizraADK\System\AgentContext;
use Vizra\VizraADK\Memory\AgentMemory;
 
class OrderLookupTool implements ToolInterface
{
public function definition(): array
{
return [
'name' => 'order_lookup',
'description' => 'Look up customer order by order ID',
'parameters' => [
'type' => 'object',
'properties' => [
'order_id' => [
'type' => 'string',
'description' => 'The order ID to look up',
],
],
'required' => ['order_id'],
],
];
}
 
public function execute(array $arguments, AgentContext $context, AgentMemory $memory): string
{
$order = Order::find($arguments['order_id']);
 
if (!$order) {
return json_encode(['error' => 'Order not found']);
}
 
// Store this interaction in memory
$memory->addFact("Recent order lookup: #{$order->id}", 1.0);
 
return json_encode([
'order_id' => $order->id,
'status' => $order->status,
'total' => $order->total,
'items' => $order->items->count(),
]);
}
}

Connect the tool to your agent:

class CustomerSupportAgent extends BaseLlmAgent
{
protected array $tools = [
OrderLookupTool::class,
];
}

Now your agent can look up real orders when customers ask. No more "I'm just an AI" excuses.

The Game Changer: Test Your AI Like You Test Your Code

Here's what sets Vizra apart from every other Laravel AI package – evaluations. Just like you wouldn't ship code without tests, why ship AI without quality assurance?

php artisan vizra:make:eval CustomerSupportQuality

This creates both your evaluation class AND a CSV file for test cases. Add some real-world scenarios:

prompt,expected_response,description
"Where is my order #12345?",order,"Should look up order status"
"I want to return this",return,"Should explain return policy"
"Your service is terrible!",sorry,"Should respond with empathy"
"What are your hours?",9 AM,"Should mention business hours"

Now define what "quality" means for your agent using Vizra's built-in assertions:

<?php
 
namespace App\Evaluations;
 
use Vizra\VizraADK\Evaluations\BaseEvaluation;
 
class CustomerSupportQuality extends BaseEvaluation
{
public string $agentName = 'customer_support';
public string $csvPath = 'app/Evaluations/data/customer_support_quality.csv';
 
public function evaluateRow(array $csvRowData, string $llmResponse): array
{
$this->resetAssertionResults();
 
// Check if response contains expected keywords
if (isset($csvRowData['expected_response'])) {
$this->assertResponseContains(
$llmResponse,
$csvRowData['expected_response']
);
}
 
// All support responses should be polite
$this->assertResponseHasPositiveSentiment($llmResponse);
 
// Don't write novels
$this->assertWordCountBetween($llmResponse, 20, 150);
 
// For complaints, ensure empathy
if (str_contains($csvRowData['prompt'], 'terrible')) {
$this->assertResponseContains($llmResponse, 'sorry');
}
 
return parent::evaluateRow($csvRowData, $llmResponse);
}
}

Notice those assertion methods? Vizra ADK includes 20+ built-in assertions for content validation, sentiment analysis, length checks, and more. No need to write complex validation logic – just use assertions like assertResponseHasPositiveSentiment() or assertWordCountBetween(). And yes, you can add your own custom assertions too!

Run your quality checks:

php artisan vizra:run:eval CustomerSupportQuality
 
Running evaluation: customer_support_quality
Processing 4 test cases...
████████████████████████ 4/4
 
Summary: Total: 4, Passed: 3 (75%), Failed: 1

One test failed the word count check – the agent wrote 180 words when explaining the return policy. This is exactly why you need evaluations! Now you can tune your agent's instructions to be more concise, or adjust your assertions to match your actual requirements.

Built by Developers, for Developers

Vizra ADK isn't just another package – it's a complete AI development framework:

  • 🚀 Native Laravel Integration - Artisan commands, facades, service providers
  • 🔧 Multi-LLM Support - OpenAI, Anthropic Claude, Google Gemini (and 10+ more via Prism)
  • 🧠 Smart Memory - Sessions, vector search, and RAG built-in
  • 🤝 Agent Delegation - Agents can work together, delegating tasks to specialized sub-agents
  • ⚡ Workflows - Orchestrate complex multi-step processes with conditional logic
  • 🧪 Built-in Testing - Evaluations framework with 20+ assertions for quality assurance
  • 📊 Web Dashboard - Beautiful UI for testing and monitoring at /vizra
  • 🔌 OpenAI Compatible API - Drop-in replacement for any OpenAI SDK
  • 🎯 Developer Friendly - Streaming responses, comprehensive tracing, detailed error messages

Start Building Today (It's Free!)

composer require vizra/vizra-adk

The entire framework is open source and MIT licensed. Build agents for customer support, data analysis, content generation, or anything else you can imagine.

Want to Scale? There's Vizra Cloud (Coming Soon)

While the ADK is forever free, we're launching Vizra Cloud for teams who want:

  • Run evaluations at scale in the cloud
  • Track quality metrics across deployments
  • Collaborate with your team on agent development
  • CI/CD integration for continuous AI quality

Beta pricing: $29/month (50% off regular pricing, locked in for 12 months).

Your AI Journey Starts Now

Stop wrestling with AI APIs. Stop hoping your AI behaves. Start building AI agents the Laravel way – with proper tools, testing, and confidence.

Ready to build something amazing?

🚀 Get Started with Vizra ADK
📖 Read the Docs
Star us on GitHub


Vizra ADK is the creation of indie developer Aaron Lumsden. Built with love for the Laravel community.

Aaron Lumsden photo

👋 Full-stack web dev by day, Indie Hacker by night. ✨ Creating software to make the 🌍 a better place. 🤖 Founder @ http://vizra.ai | Building AI agents for Laravel

Filed in:
Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Bacancy

Outsource a dedicated Laravel developer for $3,200/month. With over a decade of experience in Laravel development, we deliver fast, high-quality, and cost-effective solutions at affordable rates.

Visit Bacancy
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $3200/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Cut PHP Code Review Time & Bugs into Half with CodeRabbit logo

Cut PHP Code Review Time & Bugs into Half with CodeRabbit

CodeRabbit is an AI-powered code review tool that specializes in PHP and Laravel, running PHPStan and offering automated PR analysis, security checks, and custom review features while remaining free for open-source projects.

Cut PHP Code Review Time & Bugs into Half with CodeRabbit
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit

The latest

View all →
Laravel Boost v1.8.10 Released With New AI Prompts and Livewire v4 Support image

Laravel Boost v1.8.10 Released With New AI Prompts and Livewire v4 Support

Read article
Statamic 6 Beta Now Available image

Statamic 6 Beta Now Available

Read article
Everything new in Livewire 4 image

Everything new in Livewire 4

Read article
Cache Without Overlapping in Laravel 12.47.0 image

Cache Without Overlapping in Laravel 12.47.0

Read article
Going Real-Time with Reverb - Laravel In Practice EP17 image

Going Real-Time with Reverb - Laravel In Practice EP17

Read article
The Neuron AI Framework for PHP and Laravel image

The Neuron AI Framework for PHP and Laravel

Read article