Laravel finally has an official AI SDK. Here's why it matters.
Taylor Otwell just dropped something big: an official, first-party AI SDK for Laravel.
Taylor Otwell just dropped something big: an official, first-party AI SDK for Laravel.
This is a proper, batteries-included SDK built by Taylor himself — with the same attention to developer experience you'd expect from Laravel.
After digging through the documentation, I think this changes the game for AI in PHP.
A unified API for multiple providers
The Laravel AI SDK (laravel/ai) gives you a unified API to work with multiple AI providers:
| Feature | Providers |
|---|---|
| Text/Chat | OpenAI, Anthropic, Gemini, Groq, xAI |
| Images | OpenAI, Gemini, xAI |
| Audio | OpenAI, ElevenLabs |
| Embeddings | OpenAI, Gemini, Cohere, Jina |
The SDK also integrates deeply with Laravel's ecosystem — queues, events, broadcasting, testing.
Dedicated agent classes
Instead of scattering AI logic across your codebase, you define dedicated Agent classes:
php artisan make:agent SalesCoach
class SalesCoach implements Agent, Conversational, HasTools
{
use Promptable;
public function instructions(): string
{
return 'You are a sales coach helping reps improve their calls.';
}
public function tools(): iterable
{
return [
new RetrievePreviousTranscripts,
];
}
}
Clean. Testable. Laravel-like.
Conversation memory out of the box
Most AI wrappers make you handle conversation history yourself. Laravel AI SDK includes a trait:
use Laravel\Ai\Concerns\RemembersConversations;
class SalesCoach implements Agent, Conversational
{
use Promptable, RemembersConversations;
}
// Start conversation
$response = (new SalesCoach)->forUser($user)->prompt('Hello!');
// Continue later
$response = (new SalesCoach)
->continue($conversationId, as: $user)
->prompt('Tell me more...');
Conversations are stored in your database automatically.
Streaming and broadcasting
Stream responses to clients with native Laravel Events integration:
// Streaming endpoint
Route::get('/coach', function () {
return (new SalesCoach)->stream('Analyze this transcript...');
});
// Or broadcast to a channel
$stream = (new SalesCoach)->stream('Analyze...');
foreach ($stream as $event) {
$event->broadcast(new Channel('analysis-results'));
}
Works with Vercel AI SDK protocol out of the box.
Automatic failover between providers
Configure multiple providers, and the SDK falls back automatically:
$response = (new SalesCoach)->prompt(
'Analyze...',
provider: ['openai', 'anthropic'], // Falls back to Anthropic if OpenAI fails
);
No manual retry logic needed.
Vector search with pgvector
The SDK includes built-in support for RAG workflows:
// Migration
$table->vector('embedding', dimensions: 1536)->index();
// Query
$documents = Document::query()
->whereVectorSimilarTo('embedding', 'best wineries in Napa Valley')
->limit(10)
->get();
Your PostgreSQL handles it directly.
Complete testing fakes
Laravel's testing philosophy extends to the AI SDK:
SalesCoach::fake(['First response', 'Second response']);
// Make your API call
$response = (new SalesCoach)->prompt('Analyze this...');
// Assert it happened
SalesCoach::assertPrompted('Analyze this...');
Fakes exist for agents, images, audio, embeddings, vector stores — everything.
Compared to Prism
Prism has been my go-to for Laravel AI integration. It's excellent. Here's an honest comparison:
| Laravel AI SDK | Prism | |
|---|---|---|
| Maintainer | Laravel core team | Community |
| Images/Audio | ✅ | ❌ |
| Vector stores | ✅ Built-in | ❌ |
| Broadcasting | ✅ Native | ❌ |
| Queueing | ✅ Native | Manual |
| Testing fakes | ✅ Complete | Basic |
| Long-term support | ✅ Guaranteed | Uncertain |
Prism isn't going anywhere, and if you're already using it, don't panic. But for new projects? Laravel AI SDK is the obvious choice.
AI as a first-class citizen
Beyond the features, the signal matters.
Laravel now treats AI as a core part of the ecosystem.
That means:
- Documentation that matches Laravel's standards
- Testing patterns that feel native
- Integration with queues, events, broadcasting
- Long-term maintenance by the core team
For PHP developers who felt left behind in the AI wave, this is a big deal.
When to use it
Use Laravel AI SDK when:
- Starting a new Laravel project with AI features
- You need multi-provider support
- Building complex agents with tools and memory
- You want RAG without a separate vector database
- Testing is important (it should be)
Wait if:
- You're deep in a Prism-based project (migration path TBD)
- You need Ollama/local models (not yet supported)
- Your project goes live next week (it's still
0.x)
Coming soon: stable release
The SDK is in preview now (0.x). A livestream on February 9th with Taylor Otwell and Josh Cirre will likely announce the stable release alongside Laravel 13.
If you're building AI features in Laravel, bookmark that date.
The documentation is already excellent — worth a read even if you're not planning to use it immediately.
I offer hands-on consulting to help you resolve technical challenges and improve your CMS implementations.
Get in touch if you'd like support diagnosing or upgrading your setup with confidence.
