News

Laravel AI SDK 1.0 Adds Classification and Tool Approvals

Published
Laravel AI SDK 1.0 Adds Classification and Tool Approvals image

The Laravel team just released version 1.0 of the Laravel AI SDK, the first-party package that gives you one API for working with AI providers in a Laravel app.

The SDK was first announced in February. This release adds a new classification capability, support for two frontend chat protocols, and a new storage format for conversations. It also includes breaking changes, so check the upgrade notes below before you update.

composer require laravel/ai

Classification

Classification is now its own capability, alongside text, images, audio, and embeddings. It covers quick decisions such as routing a support ticket or flagging a comment. It runs on Jev models from TypeSafe, and the post says Jev can answer these questions "in milliseconds at a fraction of the price of traditional LLMs."

You ask a set of questions and get a typed answer for each one:

use Laravel\Ai\Classification;
use Laravel\Ai\Classification\Boolean;
use Laravel\Ai\Classification\Choice;
 
$response = Classification::of($ticket->body)->questions([
'is_urgent' => new Boolean('Does this message convey urgency?'),
'department' => new Choice('Which team should handle this?', [
'billing' => 'Payments, invoicing, refunds',
'technical' => 'Bugs, outages, integrations',
'sales' => 'Pricing, plans, upgrades',
]),
])->classify();
 
$response['is_urgent']->isTrue();
$response['department']->choice; // 'technical'

There's also a Score question type that returns a value from 0.0 to 1.0. For a single yes-or-no question, the new Str::decide macro returns a boolean, and a threshold argument sets how certain the model has to be:

Str::of($message)->decide('Is this spam?');

Classification works with TypeSafe and OpenRouter today. The team plans to add other providers behind the same API as they ship similar models.

Vercel Chat and AG-UI Streaming

The SDK can now read requests and stream responses using the Vercel Chat and AG-UI protocols, so you can pair it with frontend libraries that already speak them. Here is a Vercel chat route:

use Illuminate\Http\Request;
use Laravel\Ai\Vercel\Vercel;
 
Route::post('/chat', function (Request $request) {
$chat = Vercel::chat($request);
 
return (new SupportAgent)
->withMessages($chat->history())
->stream($chat)
->usingProtocol($chat->protocol());
});

That route reads the new message, updates the conversation history in your database, and processes any tool approvals the user submitted. For AG-UI clients such as CopilotKit, call usingAgentUserInteractionProtocol() on the stream instead. Vercel::toUiMessages() converts stored messages back into the client's format when you need to rebuild a chat screen after a page reload.

Approvable Tool Calls

A tool that implements the Approvable contract and uses the InteractsWithApprovals trait pauses the agent until someone approves it. This works great for a tool that deletes files:

use Laravel\Ai\Concerns\InteractsWithApprovals;
use Laravel\Ai\Contracts\Approvable;
use Laravel\Ai\Contracts\Tool;
 
class DeleteFile implements Approvable, Tool
{
use InteractsWithApprovals;
 
// ...
}

The response lists each pending call with the arguments the model picked. You resume the conversation with a decision for each one. A decision can approve the call, reject it with a reason the model sees, or edit the arguments before the tool runs. Approvals work with prompt, stream, queue, and the broadcast methods. We covered tool approvals when they landed in July.

Other Changes in 1.0

  • Per-step middleware: Agent middleware now runs on every generation step instead of once per prompt. Each step arrives as a PendingStep that you can change with methods such as withModel, withTools, withoutTools, and withMaxTokens. For example, you can remove an expensive tool after the agent has used it once.
  • Tool search: Wrap rarely used tools in ToolSearch and the provider loads them only when a prompt needs them. This works on OpenAI and Anthropic.
  • Code execution: The CodeExecution provider tool runs code in the provider's sandbox, on Anthropic, OpenAI, Azure, Gemini, and xAI.
  • Conversation steps: Messages now store a single steps JSON column with one entry per round-trip, and each tool result is stored with the call that produced it.
  • Usage reporting: promptTokens and completionTokens are now inputTokens and outputTokens, and include the provider's full counts across every provider.

Upgrading to 1.0

The breaking changes are mostly in conversation storage, agent middleware, token usage, and stream protocols. If you run raw SQL against the tool_calls or tool_results columns, you'll need to move it to steps. The upgrade guide also includes a backfill migration that you must run once before you deploy 1.0.

The team recommends handing most of the upgrade to an AI assistant with Laravel Boost:

composer require laravel/boost --dev
php artisan boost:install

Then run the /upgrade-ai-sdk-v1 slash command in Claude Code, Cursor, OpenCode, Gemini, or VS Code, and Boost walks your assistant through the guide one change at a time.

Read the full announcement for every code sample, and see the AI SDK documentation to get started.

Eric L. Barnes photo

Eric is the creator of Laravel News and has been covering Laravel since 2012.

Filed in

Sponsored

masteringlaravel logo
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review

The latest

View all →
Tagged Memoized Cache and Model Refreshes in Laravel 13.33 image

Tagged Memoized Cache and Model Refreshes in Laravel 13.33

Read article
Laravel Live Denmark 2026 Talks Are Now on YouTube image

Laravel Live Denmark 2026 Talks Are Now on YouTube

Read article
Live Stream: Building a Social Network in PHP in 48 Hours image

Live Stream: Building a Social Network in PHP in 48 Hours

Read article
Health for Laravel: Kubernetes Probes and Prometheus Metrics image

Health for Laravel: Kubernetes Probes and Prometheus Metrics

Read article
Fast Excel 5.x Adds Streaming Imports and Safer Exports image

Fast Excel 5.x Adds Streaming Imports and Safer Exports

Read article
What We Know About Laravel 14 image

What We Know About Laravel 14

Read article