Sponsor

The Laravel Way to Build AI Agents That Actually Work

Published
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

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article