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.

rulestest-media.md

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

Testing Images, Audio, and Transcriptions

Impact: HIGH (Fake media generation in tests)

Fake image, audio, and transcription generation to avoid real API calls. Assert that media was generated with expected parameters.

Bad Example

// Real image generation in tests — slow and expensive
test('generates product image', function () {
    $image = Image::of('Product photo')->generate();
    // Real API call, costs money, slow
    expect((string) $image)->not->toBeEmpty();
});

Good Example

use Laravel\Ai\Image;
use Laravel\Ai\Prompts\ImagePrompt;

// Fake image generation
test('generates product image', function () {
    Image::fake();

    Image::of('A sunset over the ocean')->landscape()->generate();

    Image::assertGenerated(function (ImagePrompt $prompt) {
        return $prompt->contains('sunset') && $prompt->isLandscape();
    });

    Image::assertNotGenerated('Missing prompt');
    Image::assertNothingGenerated(); // fails — was generated
});
// Fake with specific responses
test('stores generated image', function () {
    Image::fake([
        base64_encode($firstImage),
        base64_encode($secondImage),
    ]);

    $image = Image::of('A donut')->generate();
    $path = $image->store();
});
// Assert queued image generations
use Laravel\Ai\Prompts\QueuedImagePrompt;

test('queues image generation', function () {
    Image::fake();

    Image::of('A donut')->queue();

    Image::assertQueued(fn (QueuedImagePrompt $prompt) => $prompt->contains('donut'));
});
// Prevent stray image generations
test('no unexpected generations', function () {
    Image::fake()->preventStrayImages();
});
use Laravel\Ai\Audio;
use Laravel\Ai\Prompts\AudioPrompt;

// Fake audio generation
test('generates welcome audio', function () {
    Audio::fake();

    Audio::of('Welcome to our app.')->female()->generate();

    Audio::assertGenerated(function (AudioPrompt $prompt) {
        return $prompt->contains('Welcome') && $prompt->isFemale();
    });
});
use Laravel\Ai\Transcription;
use Laravel\Ai\Prompts\TranscriptionPrompt;

// Fake transcription
test('transcribes uploaded audio', function () {
    Transcription::fake(['Transcribed text from the audio file.']);

    $transcript = Transcription::fromStorage('audio.mp3')->diarize()->generate();

    Transcription::assertGenerated(function (TranscriptionPrompt $prompt) {
        return $prompt->isDiarized();
    });
});

Why

  • Fast: No image/audio generation — tests run in milliseconds
  • Deterministic: Controlled fake responses every run
  • Assertable: Verify prompts, aspect ratios, voices, and diarization settings
  • Prevent leaks: preventStrayImages() / preventStrayAudio() catch accidental real calls

Reference: Laravel AI SDK — Testing

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