hudsonly/laravel

Laravel integration for the Hudsonly AI SDK

Maintainers

Package info

gitlab.com/hudsonly/hudsonly-laravel

Homepage

Issues

pkg:composer/hudsonly/laravel

Statistics

Installs: 28

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-02-16 20:54 UTC

This package is auto-updated.

Last update: 2026-02-16 19:57:12 UTC


README

Laravel integration for the Hudsonly AI SDK. Provides a service provider, facade, and config for using Hudsonly AI services in Laravel applications.

Installation

composer require hudsonly/laravel

The package auto-discovers — no manual provider registration needed.

Publish the config file:

php artisan vendor:publish --tag=hudsonly-config

Add your API key to .env:

HUDSONLY_API_KEY=your-api-token

Usage

Via Facade

use Hudsonly\Laravel\Facades\Hudsonly;

// Text to Speech
$result = Hudsonly::tts()->generate([
    'text' => 'Hello world',
    'voice' => 'af_heart',
]);
echo $result->audioUrl;

// Speech to Text
$result = Hudsonly::transcription()->generate([
    'audio' => storage_path('app/recording.mp3'),
    'model' => 'base',
]);
echo $result->text;

// Text Embeddings
$result = Hudsonly::embeddings()->generate([
    'texts' => ['Hello', 'World'],
]);

// Avatar Video (auto-polls until complete)
$result = Hudsonly::avatar()->generate([
    'image' => storage_path('app/photo.jpg'),
    'audio' => storage_path('app/speech.mp3'),
    'model' => 'sadtalker',
]);
echo $result->videoUrl;

Via Dependency Injection

use Hudsonly\HudsonlyAI;

class TextToSpeechController extends Controller
{
    public function generate(Request $request, HudsonlyAI $hudsonly)
    {
        $result = $hudsonly->tts()->generate([
            'text' => $request->input('text'),
        ]);

        return response()->json(['audio_url' => $result->audioUrl]);
    }
}

Tasks & Credits

// List tasks
$tasks = Hudsonly::tasks()->list(['service' => 'avatar', 'status' => 'completed']);

// Check credit balance
$balance = Hudsonly::credits()->balance();
echo $balance->balance;

// Service info & rate limits
$services = Hudsonly::services();
$limits = Hudsonly::rateLimits();

Configuration

// config/hudsonly.php
return [
    'api_key' => env('HUDSONLY_API_KEY'),
    'base_url' => env('HUDSONLY_BASE_URL', 'https://ai.hudsonly.com'),
    'timeout' => env('HUDSONLY_TIMEOUT', 300),
];

Error Handling

use Hudsonly\Exceptions\AuthenticationException;
use Hudsonly\Exceptions\InsufficientCreditsException;
use Hudsonly\Exceptions\RateLimitException;
use Hudsonly\Exceptions\ValidationException;

try {
    $result = Hudsonly::tts()->generate(['text' => 'Hello']);
} catch (AuthenticationException $e) {
    // Invalid API key
} catch (InsufficientCreditsException $e) {
    // Not enough credits
} catch (RateLimitException $e) {
    // Rate limited, retry after $e->retryAfter seconds
} catch (ValidationException $e) {
    // Validation errors in $e->errors
}

Requirements

  • PHP 8.1+
  • Laravel 10, 11, or 12

License

MIT