PHP code example of runapi-ai / producer

1. Go to this page and download the library: Download runapi-ai/producer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

runapi-ai / producer example snippets




unApi\Producer\ProducerClient;

$client = new ProducerClient(); // reads RUNAPI_API_KEY

$task = $client->textToMusic->create([
    'model' => 'fuzz-2.0',
    'lyrics' => '[Verse] Morning light across the room',
    'prompt' => 'Warm acoustic pop with clear vocals',
    'title' => 'Morning Light',
    'vocal_mode' => 'exact_lyrics',
]);

$status = $client->textToMusic->get($task->id);

$result = $client->textToMusic->run([
    'model' => 'fuzz-2.0',
    'lyrics' => '[Verse] Morning light across the room',
    'prompt' => 'Cinematic orchestral music with a gradual build',
    'title' => 'Morning Light',
    'vocal_mode' => 'exact_lyrics',
]);

echo $result->audios[0]->audioUrl . PHP_EOL;