Laravel 13 was released on March 17, 2026, and it’s one of the most significant releases for Laravel developers working with AI — not because of a dramatic rewrite, but because of one specific addition: a first-party Laravel 13 AI SDK. In this guide, we’ll break down what’s new, how it compares to Laravel 12, and walk through AI agents, tools, RAG, and embeddings with practical code examples — written for both beginners and advanced developers. You can read the full official release notes on Laravel’s documentation site.
Laravel 13 vs Laravel 12: What Actually Changed
| Feature | Laravel 12 | Laravel 13 |
|---|---|---|
| AI Integration | Required third-party packages (Prism, custom wrappers) | First-party AI SDK built into the framework |
| Minimum PHP Version | PHP 8.2 | PHP 8.3 |
| Vector/Semantic Search | Not built-in, required external packages | Native vector queries with pgvector support |
| PHP Attributes | Limited use | Expanded across the framework as an optional syntax |
| API Resources | Custom JSON formatting needed | First-party JSON:API resource support |
| Breaking Changes | — | Minimal — most Laravel 12 apps upgrade with little to no code changes |
The most important takeaway: Laravel 13 is a genuinely low-effort upgrade in terms of breaking changes, while adding substantial new AI capabilities on top.
What Is the Laravel AI SDK?
The Laravel 13 AI SDK is a unified, provider-agnostic API for working with AI models directly inside your Laravel application. Instead of writing custom integration code for OpenAI, then rewriting it again if you switch to Anthropic or another provider, the AI SDK gives you one consistent interface — switching providers becomes a configuration change rather than a rewrite.
It covers five core areas:
- Text generation — chat completions, summarization, classification
- Tool-calling agents — AI agents that can call your own Laravel code as “tools”
- Embeddings — converting text into vector representations for search and comparison
- Images and audio — generating visual and audio content through the same unified API
- Vector-store integrations — connecting to vector databases for semantic search
Getting Started: Your First AI Call (Beginner Level)
At its simplest, the AI SDK lets you send a prompt and get a response with minimal setup. After installing the package via Composer and configuring your provider (OpenAI, Anthropic, etc.) in your .env file, a basic text generation call looks something like this:
use Laravel\Ai\Facades\Ai;
$response = Ai::prompt('Summarize this customer message in one sentence: ' . $message);
return (string) $response;
No manual HTTP requests, no manually handling API authentication or retries — the SDK handles that underneath.
AI Agents: Building a Custom Agent Class
Beyond simple prompts, the AI SDK supports building dedicated agent classes — reusable, purpose-built AI components that live alongside your normal Laravel application code. A simple customer support agent might look like this:
namespace App\Ai\Agents;
use Laravel\Ai\Agent;
class SupportAgent extends Agent
{
protected string $instructions = 'You are a helpful support agent for a software company. Keep answers concise and friendly.';
}
// Usage:
$response = SupportAgent::make()->prompt('How do I reset my password?');
This pattern should look familiar if you’ve read our guide on SOLID principles in Laravel — an Agent class here follows the same Single Responsibility idea we covered there: one class, one clear job, easy to test and swap out independently of the rest of your application.
Tools: Letting AI Agents Call Your Own Code
The real power of agents comes from tool-calling — giving an AI agent access to specific functions in your own codebase, so it can take real actions rather than just generating text. For example, an agent could be given a “tool” that checks order status in your database, and decide on its own when to call it based on what the user asks:
namespace App\Ai\Tools;
use Laravel\Ai\Tool;
class CheckOrderStatus extends Tool
{
public function handle(string $orderId): string
{
$order = Order::find($orderId);
return $order ? "Status: {$order->status}" : "Order not found.";
}
}
You then register this tool with an agent, and the agent decides when and how to use it based on the conversation — this is what separates a genuine “AI agent” from a simple chatbot.
RAG (Retrieval-Augmented Generation) in Laravel 13
RAG means giving an AI model relevant information from your own data before asking it to answer a question — instead of relying only on what the model already knows. Laravel 13’s native vector search support makes this significantly easier to build than in Laravel 12, where you needed external packages or manual vector database integration.
The general RAG flow in Laravel 13 looks like this:
- Convert your documents/data into embeddings (vector representations) and store them
- When a user asks a question, convert their question into an embedding too
- Run a similarity search to find the most relevant stored data
- Pass that relevant data to the AI model along with the user’s question, so it can generate an informed, grounded answer
Embeddings: Turning Text into Searchable Vectors
An embedding is a numerical representation of text that captures its meaning, allowing you to compare how similar two pieces of text are — even if they don’t share the same words. Laravel 13 makes generating embeddings straightforward:
use Illuminate\Support\Str;
$embedding = Str::toEmbeddings('How do I reset my password?');
Once you have embeddings stored (commonly in a PostgreSQL database using the pgvector extension), Laravel 13’s query builder supports running similarity searches directly — finding the closest matching stored content to a given query, which is the foundation of semantic search and RAG.
Should You Upgrade to Laravel 13?
If you’re building any feature involving AI — chatbots, semantic search, content generation, AI-assisted support tools — the Laravel 13 AI SDK removes a significant amount of boilerplate you’d otherwise need to build or import from third-party packages. Since breaking changes are minimal, most existing Laravel 12 applications can upgrade without major rework, making this a low-risk, high-value upgrade for AI-focused projects specifically.
If your application doesn’t currently need AI features, the upgrade is still worth doing eventually for the PHP 8.3 requirement and other improvements, but it’s less urgent.
Final Thoughts
The Laravel 13 AI SDK signals a real shift — AI is no longer something you bolt onto Laravel through third-party packages, but a first-class part of the framework itself. Whether you’re just getting started with a simple prompt call or building full tool-calling agents with RAG-powered semantic search, the same clean, Laravel-native patterns apply throughout. If you want to structure your AI agent classes well as your project grows, revisit our guide on SOLID principles in Laravel — the same principles apply directly to organizing Agent and Tool classes cleanly.
Frequently Asked Questions
Do I need to rewrite my app to use the Laravel 13 AI SDK?
No — the AI SDK is an addition, not a replacement for existing functionality. You can adopt it gradually, feature by feature, without needing to restructure your existing application.
Which AI providers does the Laravel AI SDK support?
It’s designed to be provider-agnostic, with support for major providers like OpenAI and Anthropic out of the box, and switching between them typically requires only a configuration change rather than code changes.
Do I need a vector database to use RAG in Laravel 13?
For production RAG systems with meaningful amounts of data, yes — commonly PostgreSQL with the pgvector extension, which Laravel 13’s query builder supports natively for similarity search.

