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.

rulesinfra-failover.md

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

Provider Failover

Impact: MEDIUM (Automatic fallback when AI providers fail)

Pass an array of providers to automatically failover when a service is down or rate-limited. Works with agents, images, and all other AI SDK features.

Bad Example

// Manual try/catch failover — verbose and fragile
try {
    $response = (new SalesCoach)->prompt(
        'Analyze this...',
        provider: Lab::OpenAI,
    );
} catch (\Exception $e) {
    try {
        $response = (new SalesCoach)->prompt(
            'Analyze this...',
            provider: Lab::Anthropic,
        );
    } catch (\Exception $e) {
        // Give up
        throw $e;
    }
}

Good Example

// Automatic failover — pass array of providers
use App\Ai\Agents\SalesCoach;
use Laravel\Ai\Enums\Lab;

$response = (new SalesCoach)->prompt(
    'Analyze this sales transcript...',
    provider: [Lab::OpenAI, Lab::Anthropic],
);
// Failover for image generation
use Laravel\Ai\Image;

$image = Image::of('A donut sitting on the kitchen counter')
    ->generate(provider: [Lab::Gemini, Lab::xAI]);
// Per-provider options with failover
use Laravel\Ai\Contracts\HasProviderOptions;

class SalesCoach implements Agent, HasProviderOptions
{
    use Promptable;

    public function providerOptions(Lab|string $provider): array
    {
        return match ($provider) {
            Lab::OpenAI => ['reasoning' => ['effort' => 'low']],
            Lab::Anthropic => ['thinking' => ['budget_tokens' => 1024]],
            default => [],
        };
    }
}

// Each fallback provider receives its own configuration
$response = (new SalesCoach)->prompt(
    'Analyze this...',
    provider: [Lab::OpenAI, Lab::Anthropic],
);

Why

  • Resilience: Automatic failover on service interruptions or rate limits
  • Zero code changes: Same agent, same prompt — just pass an array
  • Per-provider config: Each fallback can have its own options via providerOptions()
  • Works everywhere: Agents, images, audio, embeddings — all support failover

Reference: Laravel AI SDK — Failover

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