Laravel 13 Is Here: AI SDK, JSON:API Resources, Vector Search, and More
Laravel 13 is out today. It is a bigger release than it might first appear - the headline is a first-party AI SDK, but there are substantial additions for API developers too: native JSON:API resource support, semantic vector search in the query builder, centralised queue routing, and a continued expansion of PHP attribute support across the framework. Breaking changes are minimal by design.
Laravel AI SDK
Laravel 13 ships a first-party Laravel AI SDK - a unified, provider-agnostic API covering text generation, tool-calling agents, embeddings, audio, images, and vector store integrations. This is not a thin wrapper around OpenAI; it is designed to work across providers with a consistent Laravel-native interface.
A basic agent prompt looks like this:
use App\Ai\Agents\SalesCoach;
$response = SalesCoach::make()->prompt('Analyse this sales transcript...');
return (string) $response;
Image generation is equally straightforward:
use Laravel\Ai\Image;
$image = Image::of('A product shot on a white background')->generate();
$rawContent = (string) $image;
For voice and accessibility features, audio synthesis from text is built in:
use Laravel\Ai\Audio;
$audio = Audio::of('Your order has been confirmed.')->generate();
$rawContent = (string) $audio;
Embeddings are available directly from strings via Str::toEmbeddings(), which feeds directly into the vector search features covered below.
JSON:API Resources
Laravel 13 adds first-party JSON:API resources - something the community has wanted for years. These handle the full JSON:API specification: resource object serialisation, relationship inclusion, sparse fieldsets, pagination links, and the correct application/vnd.api+json response headers.
For teams building APIs that need to conform to the JSON:API specification - common in enterprise integrations and any context where consumers expect a predictable, standard response shape - this removes a significant amount of boilerplate and the need for third-party packages.
Semantic and Vector Search
Laravel 13 adds native vector query support to the query builder, making it straightforward to build semantic search against embeddings stored in PostgreSQL with pgvector. You can run similarity searches directly from Eloquent or DB queries:
$results = DB::table('documents')
->whereVectorSimilarTo('embedding', 'Best practices for API authentication')
->limit(10)
->get();
Combined with the AI SDK's Str::toEmbeddings(), this gives you a full embedding-to-retrieval workflow without reaching for external services. For teams building AI-powered search, recommendation engines, or retrieval-augmented generation (RAG) pipelines, this is a significant reduction in integration complexity.
Expanded PHP Attributes
PHP attribute support, introduced in previous releases for models and queue jobs, is significantly expanded in Laravel 13. Controllers can now declare middleware and authorisation checks directly on classes and methods:
use Illuminate\Routing\Attributes\Controllers\Authorize;
use Illuminate\Routing\Attributes\Controllers\Middleware;
#[Middleware('auth')]
class CommentController
{
#[Middleware('subscribed')]
#[Authorize('create', [Comment::class, 'post'])]
public function store(Post $post)
{
// ...
}
}
Job attributes are expanded to include #[Tries], #[Backoff], #[Timeout], and #[FailOnTimeout]. Attributes are also available for Eloquent, events, notifications, validation, testing, and resource serialisation. Existing class property syntax is unaffected - this is all opt-in.
Queue Routing
Queue configuration that previously had to live on the job class itself can now be defined centrally via Queue::route() in a service provider:
Queue::route(ProcessPodcast::class, connection: 'redis', queue: 'podcasts');
Queue::route(SendWelcomeEmail::class, connection: 'database', queue: 'emails');
This is a welcome addition for larger applications where queue configuration was scattered across dozens of job classes. Centralised routing means you can change queue assignments - for instance, moving a job to a higher-priority queue - without touching the job class itself.
Cache::touch()
A small but useful addition: Cache::touch() extends an existing cache item's TTL without fetching or re-storing the value. Previously, extending a TTL required a get followed by a put, transferring the cached value over the wire unnecessarily. The new method issues a single command at the driver level - Redis uses EXPIRE, Memcached uses TOUCH, the database driver issues an UPDATE:
Cache::touch('user_session:123', 3600);
Cache::touch('analytics_data', now()->addHours(6));
Cache::touch('report_cache', null); // extend indefinitely
Returns true on success, false if the key does not exist. Works across all cache drivers.
Enhanced CSRF Protection
Laravel's CSRF middleware has been formalised as PreventRequestForgery, adding origin-aware request verification alongside the existing token-based approach. This improves protection against cross-origin attacks while remaining compatible with existing applications - no changes required to existing CSRF token handling.
PHP 8.3 Minimum
Laravel 13 requires PHP 8.3 as the minimum version, up from PHP 8.2 in Laravel 12. PHP 8.3 introduced typed class constants, the json_validate() function, #[Override] attribute support, and various performance improvements. If you are running 8.2, upgrading PHP is a prerequisite before upgrading the framework.
Support Timeline
Laravel 13 follows the standard support cycle: bug fixes until Q3 2027, security fixes until Q1 2028. Laravel 12 continues to receive bug fixes until August 2026 and security fixes until February 2027 - there is no rush to upgrade, but the AI SDK and vector search capabilities make a compelling case for doing so sooner rather than later.
Upgrading
The team has kept breaking changes minimal by design - most applications can upgrade without significant code changes. The official upgrade guide is available in the Laravel documentation. Laravel Shift will open an automated upgrade PR for you if you want a guided path. We wrote about what was new in Laravel 12 when it launched last year - the upgrade path from 12 to 13 is considerably smoother.
