Laravel ai sdk

From AsyrafHussin/agent-skills · View interactive version

Laravel ai sdk is an AI agent skill from the GitHub repository AsyrafHussin/agent-skills. 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

How to use this skill

Skill file

Laravel AI SDK

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

When to Apply

Reference these guidelines when:

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)

2. Tools (HIGH)

3. Embeddings & Search (HIGH)

4. Media Generation (MEDIUM)

5. Files & Storage (MEDIUM)

6. Infrastructure (MEDIUM)

7. Testing (HIGH)

Essential Patterns

Creating an Agent

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

use App\Ai\Agents\SalesCoach;

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

return (string) $response;

Generating Images

use Laravel\Ai\Image;

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

$path = $image->store();

Generating Embeddings

use Illuminate\Support\Str;

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

Testing

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:

Full Compiled Document

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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.