AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Laravel Ai Sdk

skill-fusengine-agents-laravel-ai-sdk · by fusengine

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).

No reviews yet
0 installs
30 views
0.0% view→install

Install

$ agentstack add skill-fusengine-agents-laravel-ai-sdk

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets Used
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-fusengine-agents-laravel-ai-sdk)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
3mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Laravel Ai Sdk? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Laravel AI SDK

Agent Workflow (MANDATORY)

Before ANY implementation, use TeamCreate to spawn 3 agents:

  1. fuse-ai-pilot:explore-codebase - Map existing AI usage (custom HTTP clients, OpenAI PHP, etc.) to migrate
  2. fuse-ai-pilot:research-expert - Verify provider model IDs and pricing on the official Laravel AI SDK docs
  3. mcp__context7__query-docs - Pull latest laravel.com/docs/13.x/ai-sdk examples

After implementation, run fuse-ai-pilot:sniper for validation.


Overview

| 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 |


Critical Rules

  1. Use the Lab enum - Never hard-code provider strings; use Lab::Anthropic, Lab::OpenAI, etc.
  2. Configure keys in .env - One env var per provider (OPENAI_API_KEY, ANTHROPIC_API_KEY, ...) read by config/ai.php
  3. Agents are classes - Always implement Laravel\Ai\Contracts\Agent and use Promptable trait
  4. Declare tools explicitly - Override tools(): iterable to expose tool calls; never assume implicit registration
  5. Stream via routes - Return $agent->stream(...) directly from a route; do not buffer in memory

Architecture

app/
├── 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](references/templates/Agent.php.md) for a full agent


Reference Guide

| Topic | Reference | When to Consult | |-------|-----------|-----------------| | Installation | [installation.md](references/installation.md) | Setting up laravel/ai and providers | | Agents | [agents.md](references/agents.md) | Building agent classes with attributes | | Tools | [tools.md](references/tools.md) | Tool calling, FileSearch, custom tools | | Embeddings | [embeddings.md](references/embeddings.md) | Generating vectors for semantic search | | Streaming | [streaming.md](references/streaming.md) | SSE + Vercel AI SDK protocol | | Structured output | [structured-output.md](references/structured-output.md) | agent() helper + JSON Schema |

Templates

| Template | When to Use | |----------|-------------| | [Agent.php.md](references/templates/Agent.php.md) | Net new agent class | | [Tool.php.md](references/templates/Tool.php.md) | Custom tool implementation | | [EmbeddingService.php.md](references/templates/EmbeddingService.php.md) | Batch embedding generation | | [StreamingController.php.md](references/templates/StreamingController.php.md) | SSE streaming endpoint |


Quick Reference

Generate text

use App\Ai\Agents\SalesCoach;

$response = (new SalesCoach)->prompt('Summarize this call');

Generate embeddings

use Illuminate\Support\Str;

$embedding = Str::of('Napa Valley wine')->toEmbeddings();

Stream

Route::get('/coach', fn () => (new SalesCoach)->stream('Analyze this'));

→ See [Agent.php.md](references/templates/Agent.php.md) for complete example


Best Practices

DO

  • Use class-level attributes (#[Provider], #[Model], #[MaxSteps]) to lock agent configuration
  • Cache embeddings in the DB - regenerating is expensive
  • Set explicit #[Timeout] to avoid runaway long generations
  • Use usingVercelDataProtocol() for Next.js / SvelteKit frontends

DON'T

  • Don't declare an AI Agent without #[Tool] declarations if it needs to call functions - tools must be registered explicitly
  • Don't store API keys in config/ai.php directly; use env() so values aren't committed
  • Don't use Lab::OpenAI strings - use the enum for type safety
  • Don't loop manually over Embeddings::for() items; pass the full array - the SDK batches efficiently

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.