Laravel just shipped something big: a first-party AI SDK. No more stitching together half a dozen third-party packages to get AI features into your app. Let's break down what's actually in there and why it matters.
The biggest win here is the unified API. Whether you're hitting OpenAI, Anthropic, Gemini, or whatever else comes along next month, the interface stays the same. Swap providers, change models — your application code doesn't care.
If you've ever had to rip out one AI provider and replace it with another, you know how painful that can be. This solves that problem at the framework level.
1composer require laravel/ai
That's your starting point. Everything else builds on top of Laravel's conventions, so it feels like writing any other Laravel code. (laravel.com)
The SDK introduces the concept of agents — dedicated PHP classes that wrap up your prompts, instructions, tools, and conversation history into reusable components.
Think of them as specialized workers. You might have one agent that handles customer support queries, another that pulls structured data out of documents, and a third that qualifies sales leads. Each one knows its own scope, has access to specific tools, and behaves according to the instructions you give it.
It's a clean pattern. Instead of scattering AI prompts across controllers and services, you've got a single place to define how each AI interaction works. That makes things way easier to test and maintain as your app grows.
The SDK goes well beyond chat completions. You can generate images, transcribe audio, create embeddings, manage vector stores, and run document search and reranking — all from the same package.
That's a pretty significant scope. Most teams end up pulling in separate libraries for each of those capabilities, and they rarely play nicely together. Having everything under one roof, following the same patterns, is a big deal for keeping complexity under control. (laravel.com)
Here's where it gets interesting for anyone building knowledge-heavy applications. The SDK ships with built-in support for retrieval-augmented generation (RAG).
You can feed in documents, files, and embeddings to create searchable knowledge bases. Your agents can then pull relevant context from those sources when generating responses. So instead of the AI hallucinating answers about your company's refund policy, it actually reads your docs first.
This is the kind of thing that used to require a pretty serious infrastructure setup. Having it baked into Laravel makes it accessible to way more teams.
This one's quietly brilliant. If your primary AI provider hits rate limits or goes down, the SDK can automatically fail over to a backup provider. No custom retry logic, no circuit breakers you built at 2 AM — it just works.
For production apps where AI features are customer-facing, that kind of resilience matters a lot. (laravel.com)
This isn't happening in isolation. Laravel has been making a deliberate push toward AI-assisted development across the board. The framework docs now include guidance on working with AI coding tools, and the team has been thinking about how Laravel's strong conventions — controllers, queues, jobs, the whole structure — make it easier for AI systems to understand and work with your codebase.
It's a smart play. Frameworks with clear conventions give AI tools more to work with, which means better code generation and fewer headaches. (Laravel News)
If you're building Laravel apps and you've been eyeing AI features, the barrier to entry just dropped significantly. You don't need to become an expert in each provider's SDK. You don't need to figure out embeddings infrastructure from scratch. And you don't need to worry about vendor lock-in nearly as much.
The SDK gives you a Laravel-native way to build everything from simple chatbots to full-blown intelligent search systems and autonomous agents. Whether that's worth the hype remains to be seen in production, but the foundation looks solid.
If you enjoyed this article, please consider supporting our work for as low as $5 / month.
Sponsor
Written by
Writing and maintaining @LaravelMagazine. Host of "The Laravel Magazine Podcast". Pronouns: vi/vim.
Get latest news, tutorials, community articles and podcast episodes delivered to your inbox.