The Batteries-Included AI Toolkit
The Laravel AI SDK is a first-party toolkit for adding AI features to your applications. Using a helpdesk app as our playground, you’ll learn structured output, chat with memory, streaming, tool use, retrieval, and everything else you need to build AI features that are reliable, testable, and ready for production.
This is an incredibly powerful toolkit, and I can't wait to show you what you can build. Let's get going!
Series episodes
Structured Output as the Foundation
19m 53sBuild a ticket triage flow using structured output: extract priority, department, sentiment, tags, and summary from ticket text, then apply it.
Logging AI Usage
10m 37sAdd real visibility to AI calls in Laravel: build AiRun and AiUsage, log requests and token usage, and debug triage flows with confidence.
Conversation Architecture & Context Management
16m 48sBuild ticket-scoped AI chat in Laravel: add conversation IDs, create TicketAssistant, and manage context via TicketChatController.
Demoing Our Chat Agent
7m 51sAdd an Alpine chat panel to a ticket page, call your Laravel controller via fetch, handle CSRF, and prep the loop for streaming.
Streaming AI Responses to the UI
19m 30sStream AI chat replies in real time with Laravel and Alpine: add output_text, build a streaming endpoint, and render chunks as they arrive.
Giving AI the Ability to Use Tools
14m 19sStop AI guessing by adding safe tools in Laravel—generate Artisan tool classes, enforce schemas/auth, and set max_steps for real ticket data.
Retrieval Augmented Generation with Your Database
14m 17sAdd retrieval-augmented generation to your app: create embeddings, store vectors in SQLite JSON, and rank documents with cosine similarity.
Retrieval from Files and External Sources
19m 46sScale Laravel AI Q&A: upload files, store embeddings in provider vector stores, and ask questions with FileSearch using clean endpoints.
Designing for Reliability and Failure
15m 9sBuild reliable AI features with provider failover, smart timeouts, and queue fallback—create a product description agent that runs sync or async.
Controlling Cost Before It Controls You
13m 51sControl AI token costs in Laravel: correlate runs and usage via invocation_id, auto-log with events, and enforce a daily budget middleware.
Safety Layers and Guardrails
13m 48sAdd trusted safety layers: wire Input/OutputSafetyMiddleware, screen prompts, filter responses, and lock WebSearch to approved domains.
Testing AI Features Without Hitting the API
11m 33sTest AI features fast and safely—fake providers, keep tests local and deterministic, and fail fast with preventStrayPrompts guards.
Exposing Your AI Features with MCP
12m 49sExpose Laravel AI features safely with MCP: install Laravel MCP, publish a triageTicket tool, and verify responses with the inspector.




