Source path: app/Services/Ai/Image/HuggingFaceImage.php
Extracted from supplied specification. Review before copying into application.

<?php
namespace App\Services\Ai\Image;

use App\Services\Ai\ImageProvider;
use Illuminate\Support\Facades\Http;

class HuggingFaceImage implements ImageProvider
{
    public function configured(array $c): bool { return !empty($c['api_key']) && !empty($c['model']); }

    public function generate(string $prompt, string $size, array $c): string
    {
        [$w, $h] = array_map('intval', explode('x', $size));
        $res = Http::withToken($c['api_key'])->timeout(150)->post(
            "https://router.huggingface.co/hf-inference/models/{$c['model']}",
            ['inputs' => $prompt, 'parameters' => ['width' => $w, 'height' => $h]]
        )->throw();
        return $res->body(); // image bytes
    }
}
