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 efficientlydevelopment
Use when optimizing entity-based / semantic SEO 2026. Covers entity maps, Google Knowledge Graph resolution, salience scoring, passage-level ranking, about/sameAs/knowsAbout schema, Cloud Natural Language API validation.
development
Use when running SEO, GEO, schema, Core Web Vitals, sitemap, hreflang, E-E-A-T, AI Overviews, technical SEO, or structured data tasks. Covers full-site audits, single-page analysis, schema markup, content quality, AI search optimization, local SEO, sitemap/robots, internal linking, semantic clustering, and search experience.
development
Use when optimizing search experience (SXO). Covers intent matching, user personas, user stories, page-type analysis, dwell time, scroll depth, pogo-sticking prevention.
development
Use when optimizing local SEO. Covers Google Business Profile, NAP consistency, citations, reviews acquisition, Local Pack ranking, location pages, LocalBusiness schema.