plugins/laravel-expert/skills/laravel-ai-sdk/SKILL.md
Use when integrating AI agents, tool calling, embeddings, structured output, or streaming in Laravel 13 via the `laravel/ai` package. Covers 14+ providers (OpenAI, Anthropic, Gemini, Azure, Groq, DeepSeek, Ollama, Mistral, xAI, Cohere, ElevenLabs, Jina, VoyageAI, OpenRouter).
npx skillsauth add fusengine/agents laravel-ai-sdkInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Before ANY implementation, use TeamCreate to spawn 3 agents:
laravel.com/docs/13.x/ai-sdk examplesAfter implementation, run fuse-ai-pilot:sniper for validation.
| Feature | Description |
|---------|-------------|
| Unified API | Same code surface for 14+ providers via Lab enum |
| Agents | Class-based with Agent contract + Promptable trait |
| Tool calling | First-party FileSearch + custom tools per agent |
| Embeddings | Embeddings::for([...])->generate() + Str::toEmbeddings() |
| Streaming | Native SSE + Vercel AI SDK protocol compatibility |
| Structured output | agent(schema: fn ($s) => ...) with JsonSchema |
Lab enum - Never hard-code provider strings; use Lab::Anthropic, Lab::OpenAI, etc..env - One env var per provider (OPENAI_API_KEY, ANTHROPIC_API_KEY, ...) read by config/ai.phpLaravel\Ai\Contracts\Agent and use Promptable traittools(): iterable to expose tool calls; never assume implicit registration$agent->stream(...) directly from a route; do not buffer in memoryapp/
├── Ai/
│ ├── Agents/
│ │ └── SalesCoach.php # implements Agent, uses Promptable
│ ├── Tools/
│ │ └── SearchProducts.php # custom tool class
│ └── Services/
│ └── EmbeddingService.php # Embeddings::for() wrapper
config/
└── ai.php # providers, default models
.env # *_API_KEY entries
→ See Agent.php.md for a full agent
| Topic | Reference | When to Consult |
|-------|-----------|-----------------|
| Installation | installation.md | Setting up laravel/ai and providers |
| Agents | agents.md | Building agent classes with attributes |
| Tools | tools.md | Tool calling, FileSearch, custom tools |
| Embeddings | embeddings.md | Generating vectors for semantic search |
| Streaming | streaming.md | SSE + Vercel AI SDK protocol |
| Structured output | structured-output.md | agent() helper + JSON Schema |
| Template | When to Use | |----------|-------------| | Agent.php.md | Net new agent class | | Tool.php.md | Custom tool implementation | | EmbeddingService.php.md | Batch embedding generation | | StreamingController.php.md | SSE streaming endpoint |
use App\Ai\Agents\SalesCoach;
$response = (new SalesCoach)->prompt('Summarize this call');
use Illuminate\Support\Str;
$embedding = Str::of('Napa Valley wine')->toEmbeddings();
Route::get('/coach', fn () => (new SalesCoach)->stream('Analyze this'));
→ See Agent.php.md for complete example
#[Provider], #[Model], #[MaxSteps]) to lock agent configuration#[Timeout] to avoid runaway long generationsusingVercelDataProtocol() for Next.js / SvelteKit frontends#[Tool] declarations if it needs to call functions - tools must be registered explicitlyconfig/ai.php directly; use env() so values aren't committedLab::OpenAI strings - use the enum for type safetyEmbeddings::for() items; pass the full array - the SDK batches efficientlytesting
Copy self-audit and ban-lists — filler verbs/hype adjectives, slop placeholder names, fake-precise numbers, Title Case headlines, humor in error copy ('Oops!'), em-dash crutch, one copy register per page.
development
Logged-in web apps — dashboards, auth flows, settings, onboarding, data tables, command palettes, modals, toasts. Register `product`: density and glance-speed over marketing polish, no hero/CTA-tricks, every data surface covers empty/loading/error explicitly, tables and dataviz follow preattentive-processing rules.
development
Marketing sites, landing pages, campaign pages — register `brand` (design IS the product). Structure comes from the register's POV + a macrostructure pick, never from copying an inspiration site's section flow. Hero discipline, deviated section order, asymmetric grids, and a silhouette lookalike-test gate before ship.
development
Token-strategy core — OKLCH color rules, neutral tinting, accent-commitment levels, type scale, 8pt spacing grid, touch targets, and the canonical output format of design-system.md (the file the harness gates on). This is routing step 1 of design-method/SKILL.md — read it before design-web/design-webapp/design-ios/design-android, before picking or auditing a single color/type/spacing value.