Skip to main content
← All articles
laravel

Laravel now ships a first-party AI SDK — and it's very Laravel

Laravel now ships a first-party AI SDK — and it's very Laravel

Laravel now has an official, first-party AI SDK: one composer require laravel/ai and you get text generation, agents, structured output, embeddings, images, audio and RAG behind a single expressive API. My day job is Drupal, where AI integration usually means a contrib module and a prayer, but I keep a Laravel side-eye going — and this one made me sit up.

What it actually is

Taylor Otwell previewed the SDK at Laracon India on 31 January 2026, and it shipped publicly in early February as a beta, with the docs now living under Laravel 13. It's MIT-licensed and developed in the open at laravel/ai on GitHub.

The pitch is a unified API over a genuinely wide provider matrix — OpenAI, Anthropic, Gemini, Azure, Bedrock, Groq, xAI, DeepSeek, Mistral, Ollama and OpenRouter for text; ElevenLabs for speech; Cohere, Jina and VoyageAI for embeddings and reranking. You swap providers in config without touching application code, and there's automatic failover to a backup provider when one rate-limits or falls over. That last bit is not something most wrappers give you for free.

  • Text generation and streaming, structured (schema-validated) output
  • Agents with tools, memory, sub-agents and middleware
  • Image generation, text-to-speech, transcription
  • Embeddings, reranking, and file/vector stores for RAG (with native pgvector support)
  • Provider tools like web search and file search, plus queueing and broadcasting

Agents are just PHP classes

The core abstraction is the agent: a plain class implementing small contracts, with a fluent JSON schema for structured output. This is from the official docs, trimmed:

class SalesCoach implements Agent, HasStructuredOutput
{
    use Promptable;

    public function instructions(): Stringable|string
    {
        return 'You are a sales coach, analyzing transcripts and providing feedback and an overall sales strength score.';
    }

    public function schema(JsonSchema $schema): array
    {
        return [
            'feedback' => $schema->string()->required(),
            'score' => $schema->integer()->min(1)->max(10)->required(),
        ];
    }
}

$response = (new SalesCoach)->prompt('Analyze this sales transcript...');

return $response['score'];

Tools follow the same pattern — a class with a description, a handle() method and a schema — and the SDK executes them automatically during agent runs. It reads like Laravel, which is exactly the point.

The testing story is the sleeper feature

Every capability ships with fakes: SalesCoach::fake(), Image::fake(), and assertions like SalesCoach::assertPrompted('Analyze this...'). Deterministic AI code in CI, no tokens burned. As someone who has stubbed one too many third-party APIs by hand, this is what I want from every AI wrapper and rarely get.

Every AI wrapper demos well. Test fakes and provider failover are where this one actually earns its keep.

Caveats before you rip out Prism

Field notes wouldn't be honest without the wrinkles I found:

  1. It's still pre-1.0. Despite the Laravel 13 docs placement, the package sat at v0.9.0 as of 7 July 2026, with 40 releases in about five months. Expect churn if you adopt now.
  2. Prism got there first. The community package Prism PHP has been battle-tested in production for over a year and supports a similar provider spread. The first-party SDK is broader in scope (audio, RAG, agents), but this is a classic case of a framework absorbing its ecosystem — fine if you're starting fresh, awkward if you bet on Prism.
  3. Postgres is the happy path. The vector store side leans on pgvector; early reviewers noted vector search works best on PostgreSQL. MySQL shops should check before committing.
  4. Trust backdrop. Reception was coloured by the earlier Laravel Boost controversy, where a guideline recommending Laravel Cloud inside AI agent context drew a scathing Hacker News thread about ads in your agent. That was Boost, not this SDK — but it explains why some people read first-party AI tooling with one eyebrow raised.
laravel/ai repository on GitHub
laravel/ai on GitHub: MIT-licensed, around 1,000 stars — and, note, still v0.9.x in July 2026.

Watch the walkthrough

The official video — Taylor Otwell and Josh Cirre building with the SDK — is linked from the landing page and worth the time:

My take from the Drupal trenches: the abstraction is the right shape — agents as classes, schemas as code, fakes as first-class citizens. I'd happily use it on a greenfield Laravel project today; I'd just pin my versions and read the changelog until 1.0 lands.

Links

BM
Blue Moose
The moose behind Blue Moose. Full-stack PHP developer — Drupal by day, Symfony by night, tests always.