Laravel 13 Ships With a First-Party AI SDK: What PHP Developers Need to Know
For the past couple of years, if you wanted to build an AI agent, every tutorial pointed to Python. LangChain, vector stores, embedding pipelines — all Python-first, sometimes Python-only. PHP developers were left with three options: learn Python, build a Python microservice and call it over HTTP from Laravel, or settle for raw API calls that barely scratched the surface of what agents can do.
Laravel 13 changes that.
Released on March 17, 2026, Laravel 13 ships with the Laravel AI SDK — a first-party package that gives PHP developers a complete, idiomatic foundation for building AI agents: tools, memory, structured output, streaming, multi-agent workflows, vector search, and native integration with Laravel's queues, filesystem, and Eloquent. You don't need Python. You don't need a microservice. You write PHP.
Here's what the SDK actually offers, why it matters for solo developers and small teams, and how to start building with it today.
What's New in Laravel 13
Before diving into the AI SDK, the framework itself got meaningful upgrades:
PHP 8.3 is now required. Laravel 13 drops support for PHP 8.2. If you're still on 8.2, upgrade first — the performance and syntax improvements are worth it.
First-class PHP Attributes. You can now configure models, jobs, and console commands using native PHP attributes instead of class properties. It's fully optional and backward-compatible, but it makes code more readable and easier for AI agents to parse:
#[Table('users', key: 'user_id', keyType: 'string', incrementing: false)]
#[Hidden(['password'])]
#[Fillable(['name', 'email'])]
class User extends Model {}
Queue routing by class. Queue::route(ProcessPodcast::class, connection: 'redis', queue: 'podcasts') lets you define default queue and connection rules for specific jobs in one central place — cleaner than scattering onQueue() calls across your codebase.
Semantic / vector search in the query builder. Laravel 13 adds native vector query support, embedding workflows, and similarity search against PostgreSQL + pgvector:
$documents = DB::table('documents')
->whereVectorSimilarTo('embedding', 'Best wineries in Napa Valley')
->limit(10)
->get();
Cache::touch(). A small but useful addition — extend a cached item's TTL without rewriting the value.
But the headline feature is the AI SDK.
What the Laravel AI SDK Actually Is
The Laravel AI SDK (laravel/ai) is a first-party package that provides a unified PHP API for interacting with 14 AI providers: OpenAI, Anthropic, Google Gemini, Groq, Mistral, DeepSeek, xAI, Ollama, Azure OpenAI, Cohere, OpenRouter, Jina, VoyageAI, and ElevenLabs.
The core building block is an Agent class — a PHP class that encapsulates instructions, conversation history, tools, and an optional output schema. Agents integrate natively with Laravel queues, filesystems, broadcasting, and Eloquent.
Here's what that means in practice:
Tool Calling
Tools are PHP classes that implement a handle method and a JSON schema. The model decides when to call them. The SDK executes them and returns the result to the model automatically.
class SearchKnowledgeBase implements Tool
{
public function schema(): array
{
return [
'type' => 'object',
'properties' => [
'query' => ['type' => 'string'],
],
'required' => ['query'],
];
}
public function handle(array $arguments): string
{
$results = Document::whereVectorSimilarTo('embedding', $arguments['query'])
->limit(5)
->get();
return $results->pluck('content')->join("\n\n");
}
}
Structured Output
Agents that implement HasStructuredOutput return typed, validated JSON. You define the schema, and the SDK handles the rest:
class TriageAgent extends Agent implements HasStructuredOutput
{
public function schema(): array
{
return [
'type' => 'object',
'properties' => [
'priority' => ['type' => 'string', 'enum' => ['low', 'medium', 'high', 'critical']],
'category' => ['type' => 'string'],
'assigned_team' => ['type' => 'string'],
'summary' => ['type' => 'string'],
],
'required' => ['priority', 'category', 'assigned_team', 'summary'],
];
}
}
Streaming
Agents can stream responses directly to the browser as server-sent events:
return $agent->stream();
Queue Support
Long-running agent calls can be dispatched as background jobs:
$agent->queue();
This is critical for production. Embedding a 10-page PDF can take three to five seconds — you don't want that blocking an HTTP request.
Why This Matters for Solo Developers
If you're a solo developer or running a small team, the Laravel AI SDK removes three major friction points:
1. No Python required. You can build AI agents in the language and framework you already know. Your existing Laravel patterns — service containers, Eloquent, queues, migrations — all work out of the box.
2. No microservice complexity. You don't need to spin up a Python service, manage inter-service communication, or debug HTTP timeouts between Laravel and a Python agent. Everything lives in one codebase.
3. Infrastructure you already have. The SDK is designed to work with Laravel Cloud's managed PostgreSQL (with pgvector), queue workers, and encrypted environment variables. For local development, you can use Docker Compose with the pgvector extension.
Laravel PAO: A Quiet but Important Addition
Released alongside the AI SDK, Laravel PAO (PHP Agent-Optimized Output) detects when supported PHP tools are being run by an AI agent — Claude Code, Cursor, Devin, Gemini CLI, and others — and returns compact, structured JSON instead of decorated terminal output.
For PHPUnit, Pest, Paratest, PHPStan, Rector, and Artisan commands, PAO strips ANSI colors, dot leaders, and decorative tables. The agent gets the same information with fewer tokens to process.
This is included as a dev dependency in new Laravel applications by default. Your terminal experience stays the same; PAO only activates when an agent is detected.
What You Can Realistically Ship Today
The Laravel AI SDK is production-ready. Here are three realistic use cases you can build now:
Document search agent. Upload files, chunk and embed them asynchronously, and let users ask natural-language questions against your knowledge base. The Laravel blog has a full tutorial on this.
Support ticket triage. Classify incoming tickets by priority, route them to the right team, and draft initial responses by searching past resolved issues.
Content moderation. Scan user-generated content for policy violations, classify severity, and either auto-approve, flag for review, or reject — all with structured output you can validate and act on.
Getting Started
Install the SDK:
composer require laravel/ai
Add at least one provider key to your .env:
OPENAI_API_KEY=sk-...
# or
ANTHROPIC_API_KEY=sk-ant-...
Generate an agent:
php artisan make:agent SupportAgent
Define its instructions, tools, and output schema in the generated class. The SDK handles provider selection, conversation persistence, and execution.
The Bottom Line
The Laravel AI SDK is not a wrapper around raw API calls. It's a full agent framework built on Laravel's conventions, with a testing layer, conversation persistence, queue support, streaming, embeddings, vector stores, image generation, and audio transcription.
For PHP developers who have watched the AI agent conversation happen in Python, this is the moment that conversation becomes accessible. You don't need to switch stacks. You don't need to hire a Python engineer. You build agents the same way you build everything else — with Laravel.
Sources
- Laravel 13 Released — Laravel News
- Building AI Agents with Laravel: No Python Required — Laravel Blog
- Laravel AI Integration: Build a Document Search Agent — Laravel Blog
- Introducing Laravel PAO: Cleaner Output for AI Agents — Laravel Blog
- Laravel Framework v13.14.0 Release — GitHub
Follow BuildWithAbdallah for more hands-on engineering content on Laravel, AI agents, and production workflows.