
Remember when you had to wire up three different AI packages just to add chat, embeddings, and image generation to your Laravel app? Each with its own configuration, error handling, and testing approach? Those days are officially over.
Laravel just dropped an official AI SDK, and it's exactly what the ecosystem needed. Let's break down why this matters and how it'll change the way you build AI-powered applications.
The Problem It Solves
If you've tried integrating AI into Laravel before, you know the pain:
- Vendor lock-in: Pick OpenAI today, regret it when Anthropic releases Claude 5 tomorrow
- Inconsistent APIs: Every package has different method names, return types, and error formats
- Testing nightmares: Mocking HTTP calls to AI providers is tedious and brittle
- Configuration sprawl: API keys, endpoints, and model names scattered across multiple config files
The Laravel AI SDK solves all of this with one elegant, framework-native package.
What You Get Out of the Box
The SDK is comprehensive. We're talking:
Multi-Provider Support
1use Illuminate\Support\Facades\AI;
2
3// Switch providers with zero code changes
4AI::provider('anthropic')->generate('Explain Laravel queues');
5AI::provider('openai')->generate('Explain Laravel queues');
6AI::provider('gemini')->generate('Explain Laravel queues');
Anthropic, OpenAI, Google Gemini, ElevenLabs—they're all supported. Swap models in a single line. Your application logic stays clean.
Built-in Agents with Tools
This is where it gets exciting. The SDK includes a full agent framework:
1use Illuminate\AI\Agent;
2use App\AI\Tools\SearchDatabase;
3use App\AI\Tools\SendEmail;
4
5$agent = Agent::make()
6 ->withTools([SearchDatabase::class, SendEmail::class])
7 ->withMemory(session: true)
8 ->prompt('Find users who signed up last week and email them a welcome message');
9
10$result = $agent->run();
Tools, memory, structured outputs, streaming—all testable with built-in fakes. No more cobbling together random packages.
Automatic Fallbacks
Rate limited by OpenAI? The SDK can automatically fall back to Anthropic:
1AI::withFallback(['openai', 'anthropic', 'gemini'])
2 ->generate($prompt);
This alone is worth the upgrade. Production resilience without complex retry logic.
Beyond Text: Full Multimodal Support
One package handles:
- Text generation (chat, completions)
- Image generation and analysis
- Audio generation (via ElevenLabs)
- Speech transcription
- Embeddings for semantic search
- Reranking for better search results
- Vector store integration
- Web search
- File search
1// Generate an image
2$image = AI::image('A bear wearing a top hat, digital art');
3
4// Transcribe audio
5$text = AI::transcribe($audioFile);
6
7// Create embeddings
8$vectors = AI::embed(['Document 1', 'Document 2']);
All with the same consistent API patterns you expect from Laravel.
Why First-Party Matters
Community packages have served us well, but first-party support changes the game:
- Long-term maintenance: Laravel's core team backs it
- Integration depth: Works seamlessly with queues, events, and the service container
- Testing utilities:
AI::fake() just works, like Http::fake()
- Documentation: Official docs at laravel.com, not scattered READMEs
- Upgrade path: Follows Laravel's semantic versioning
This is the same pattern we saw with Sanctum, Cashier, and Jetstream. When Laravel goes first-party, the ecosystem aligns.
Testing That Doesn't Suck
The built-in fakes make testing AI features trivial:
1use Illuminate\Support\Facades\AI;
2
3public function test_generates_product_description(): void
4{
5 AI::fake([
6 'generate' => 'A beautifully crafted product description',
7 ]);
8
9 $response = $this->post('/products/1/generate-description');
10
11 AI::assertGenerated();
12 AI::assertPromptContains('product description');
13}
No HTTP mocking. No brittle assertions on request payloads. Just clean, readable tests.
Getting Started
The SDK ships with Laravel 12.x. If you're on an earlier version, you can install it separately:
1composer require laravel/ai
Configure your providers in config/ai.php:
1return [
2 'default' => env('AI_PROVIDER', 'anthropic'),
3
4 'providers' => [
5 'anthropic' => [
6 'key' => env('ANTHROPIC_API_KEY'),
7 'model' => 'claude-3-5-sonnet',
8 ],
9 'openai' => [
10 'key' => env('OPENAI_API_KEY'),
11 'model' => 'gpt-4-turbo',
12 ],
13 ],
14];
And you're ready to build.
What This Means for Beartropy Users
If you're using Beartropy packages, this is great news. The AI SDK's design patterns align perfectly with how we build tools—clean APIs, testability first, framework-native conventions.
Expect future Beartropy packages to leverage the AI SDK for features like:
- Intelligent form suggestions
- AI-powered content moderation
- Smart search in admin panels
- Automated data analysis
Live Stream Coming Up
On February 9th, Taylor Otwell and Josh Cirre are doing a live stream to build something with the SDK. If you want to see it in action from the creators themselves, don't miss it.
The Bottom Line
Laravel's AI SDK isn't just another package—it's the foundation for AI-native Laravel development. Provider-agnostic, fully testable, and designed with the same care as every first-party Laravel tool.
Stop juggling SDKs. Start building.
Based on the official announcement from Laravel News. Explore the SDK at laravel.com/ai and check out the full documentation.