All skills
asyrafhussin avatar

/laravel-ai-sdk

@7221662

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.

Use this Skill: https://skilld.dev/gh/asyrafhussin/agent-skills/laravel-ai-sdk

This session only. Nothing lands on disk.

rulesagent-streaming-async.md

≈752 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Streaming, Broadcasting, and Queueing

Impact: HIGH (Real-time and background AI processing)

Stream agent responses for real-time UX, broadcast to channels for live updates, or queue prompts for background processing.

Bad Example

// Blocking request — user waits for entire response before seeing anything
Route::post('/coach', function (Request $request) {
    $response = (new SalesCoach)->prompt($request->input('message'));

    // User stares at spinner for 10+ seconds
    return response()->json(['reply' => (string) $response]);
});

Good Example

// Stream — return SSE directly from route
use App\Ai\Agents\SalesCoach;

Route::get('/coach', function () {
    return (new SalesCoach)->stream('Analyze this sales transcript...');
});
// Stream with completion callback
use Laravel\Ai\Responses\StreamedAgentResponse;

Route::get('/coach', function () {
    return (new SalesCoach)
        ->stream('Analyze this sales transcript...')
        ->then(function (StreamedAgentResponse $response) {
            // $response->text, $response->events, $response->usage
        });
});
// Stream using Vercel AI SDK protocol (for Next.js/React frontends)
Route::get('/coach', function () {
    return (new SalesCoach)
        ->stream('Analyze this sales transcript...')
        ->usingVercelDataProtocol();
});
// Iterate through stream events manually
$stream = (new SalesCoach)->stream('Analyze this transcript...');

foreach ($stream as $event) {
    // Process each chunk
}
// Broadcast streamed events to a channel
use Illuminate\Broadcasting\Channel;

$stream = (new SalesCoach)->stream('Analyze this transcript...');

foreach ($stream as $event) {
    $event->broadcast(new Channel('channel-name'));
}

// Or queue the entire operation and broadcast automatically
(new SalesCoach)->broadcastOnQueue(
    'Analyze this transcript...',
    new Channel('channel-name'),
);
// Queue — process in background with then/catch callbacks
use Laravel\Ai\Responses\AgentResponse;

Route::post('/coach', function (Request $request) {
    (new SalesCoach)
        ->queue($request->input('transcript'))
        ->then(function (AgentResponse $response) {
            // Handle response in background
        })
        ->catch(function (Throwable $e) {
            // Handle failure
        });

    return back();
});

Why

  • Better UX: Streaming shows tokens as they arrive — no waiting for full response
  • Scalable: Queueing offloads long prompts to background workers
  • Real-time: Broadcasting pushes updates to WebSocket clients
  • Protocol support: Vercel AI SDK protocol for seamless React/Next.js integration

Reference: Laravel AI SDK — Streaming

Source: SKILL.md on GitHub

1 warning16d4 checks · Risk MEDIUM
  • Gen Agent Trust Hub16d

    The skill provides a comprehensive guide for the Laravel AI SDK but contains deceptive metadata claiming authorship by the 'Laravel Community' despite being associated with the user 'asyrafhussin'. It also presents an indirect prompt injection surface by documenting patterns for ingesting untrusted data (such as transcripts and external URLs) while granting agents capabilities like file system storage and network access.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 7221662. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 7 months ago
Other metadata
metadata
{
  "author": "Laravel Community",
  "version": "1.0.0",
  "laravelVersion": "13.x",
  "phpVersion": "8.3+"
}

README badge

README badge for asyrafhussin/agent-skills/laravel-ai-sdk