Skip to content
Back to skills

Laravel Ai Sdk

ASecurity

Laravel AI SDK for building AI-powered features. Use when creating agents, generating images or audio, working with embeddings, vector search, or testing AI features. Triggers on tasks involving laravel/ai, AI agents, tool-calling, structured output, streaming, embeddings, reranking, or AI faking in tests. Not for Laravel for Rust apps (laravel-rust crate).

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentsrustgophptestingbackend

Security analysis

A100/100

Pro scans all 19 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add airshell/laravel-php-to-rust --skill laravel-ai-sdk --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Laravel Ai Sdk?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Laravel Ai Sdk
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/airshell-laravel-ai-sdk/badge)](https://www.skillsdirectory.com/skills/airshell-laravel-ai-sdk)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: laravel-ai-sdk
description: Laravel AI SDK for building AI-powered features. Use when creating agents, generating images or audio, working with embeddings, vector search, or testing AI features. Triggers on tasks involving laravel/ai, AI agents, tool-calling, structured output, streaming, embeddings, reranking, or AI faking in tests. Not for Laravel for Rust apps (laravel-rust crate).
license: MIT
metadata:
  author: Laravel Community
  version: "1.1.1"
  laravelVersion: "13.x"
  phpVersion: "8.3+"
---

# Laravel AI SDK

Comprehensive guide for building AI-powered features with the Laravel AI SDK (`laravel/ai`). Contains 19 rules across 7 categories covering agents, tools, tool approval, media generation, embeddings, vector stores, and testing.

**Version 1.1.1 (December 2026).** Targets `laravel/ai` ^1.0, tested on 1.4 (1.4.2).

## When to Apply

Reference these guidelines when:
- Creating AI agents with instructions, tools, and structured output
- Prompting agents with conversation context
- Streaming or queueing agent responses
- Writing step middleware, stopping runs, or tracking token usage and cost
- Requiring human approval before a tool runs
- Generating images, audio, or transcriptions
- Creating and querying vector embeddings
- Building RAG (retrieval-augmented generation) features
- Testing AI features with fakes and assertions

**Not for Laravel for Rust.** If the project is a Laravel for Rust app (its `Cargo.toml` depends on the `laravel-rust` crate), this skill does not apply: it assumes a Laravel PHP backend. Use the agent skills the app ships in `.agents/skills/` and the version-matched docs bundled with the crate.

## Rule Categories by Priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Agents | CRITICAL | `agent-` |
| 2 | Tools | HIGH | `tool-` |
| 3 | Embeddings & Search | HIGH | `embed-` |
| 4 | Media Generation | MEDIUM | `media-` |
| 5 | Files & Storage | MEDIUM | `files-` |
| 6 | Infrastructure | MEDIUM | `infra-` |
| 7 | Testing | HIGH | `test-` |

## Quick Reference

### 1. Agents (CRITICAL)

- `agent-create-configure` - Create agents with artisan, PHP attribute configuration
- `agent-prompting` - Prompt agents, conversation context, RemembersConversations, ownership check before `continue()`
- `agent-structured-output` - Structured output with JSON schema
- `agent-streaming-async` - Streaming, broadcasting, and queueing responses
- `agent-middleware` - Step middleware (`PendingStep`), `then()` on `StepResponse`, `Stop::when()` / `Stop::unless()`
- `agent-caching-usage` - `#[CacheInstructions]` / `#[CacheToolDefinitions]`, `inputTokens` / `outputTokens`, cost per token category
- `agent-anonymous` - Anonymous agents for quick interactions

### 2. Tools (HIGH)

- `tool-create` - Create custom tools with schema and `handle(Request $request)`; dependencies via the constructor
- `tool-provider` - Provider tools: WebSearch, WebFetch, FileSearch, SimilaritySearch, and which providers run them
- `tool-approval` - Human approval with `Approvable`, `InteractsWithApprovals`, `Decisions`, and a conversation ownership check

### 3. Embeddings & Search (HIGH)

- `embed-generate-cache` - Generate, store, and cache vector embeddings
- `embed-rerank` - Rerank documents and collections by relevance

### 4. Media Generation (MEDIUM)

- `media-images` - Generate, store, and queue images
- `media-audio-transcription` - Text-to-speech and speech-to-text

### 5. Files & Storage (MEDIUM)

- `files-vector-stores` - File storage and vector stores for RAG

### 6. Infrastructure (MEDIUM)

- `infra-failover` - Failover on `FailoverableException` only, model per provider

### 7. Testing (HIGH)

- `test-agents` - Fake agents, assert prompts, prevent stray prompts
- `test-media` - Fake images, audio, and transcriptions
- `test-data` - Fake embeddings, reranking, files, and vector stores

## Essential Patterns

### Creating an Agent

```php
<?php

namespace App\Ai\Agents;

use Laravel\Ai\Contracts\Agent;
use Laravel\Ai\Promptable;

class SalesCoach implements Agent
{
    use Promptable;

    public function instructions(): string
    {
        return 'You are a sales coach, analyzing transcripts and providing feedback.';
    }
}
```

### Prompting

```php
use App\Ai\Agents\SalesCoach;

$response = SalesCoach::make()->prompt('Analyze this sales transcript...');

return (string) $response;
```

### Generating Images

```php
use Laravel\Ai\Image;

$image = Image::of('A donut sitting on the kitchen counter')
    ->landscape()
    ->generate();

$path = $image->store();
```

### Generating Embeddings

```php
use Illuminate\Support\Str;

$embeddings = Str::of('Napa Valley has great wine.')->toEmbeddings();
```

### Testing

```php
use App\Ai\Agents\SalesCoach;

SalesCoach::fake(['First response', 'Second response']);

SalesCoach::make()->prompt('Analyze this...');

SalesCoach::assertPrompted('Analyze this...');
```

## How to Use

Read individual rule files for detailed explanations and code examples.

Each rule file contains:
- YAML frontmatter with metadata (title, impact, tags)
- Brief explanation of why it matters
- Bad Example with explanation
- Good Example with explanation
- Laravel 13 and PHP 8.3 specific context and references

## Full Compiled Document

For the complete guide with all rules expanded: `AGENTS.md`

Files in this skill

  • AGENTS.md69.2 KB
  • README.md2.3 KB
  • SKILL.md5.2 KB
  • rules/agent-anonymous.md2 KB
  • rules/agent-caching-usage.md4.8 KB
  • rules/agent-create-configure.md3.9 KB
  • rules/agent-middleware.md4.4 KB
  • rules/agent-prompting.md4.2 KB
  • rules/agent-streaming-async.md2.9 KB
  • rules/agent-structured-output.md2.1 KB
  • rules/embed-generate-cache.md3.4 KB
  • rules/embed-rerank.md2.3 KB
  • rules/files-vector-stores.md3.2 KB
  • rules/infra-failover.md4.1 KB
  • rules/media-audio-transcription.md2.7 KB
  • rules/media-images.md2.3 KB
  • rules/test-agents.md3.3 KB
  • rules/test-data.md3.5 KB
  • rules/test-media.md3.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.