1. Go to this page and download the library: Download modelslab/php 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/ */
modelslab / php example snippets
ModelsLab\ModelsLab;
use ModelsLab\Schemas\Text2Speech;
$apiKey = 'your-api-key';
$modelslab = new ModelsLab($apiKey);
$tts = new Text2Speech([
'prompt' => 'Hello from ModelsLab!',
'voice_id' => 'madison',
'language' => 'english'
]);
$response = $modelslab->audio()->textToSpeech($tts);
echo json_encode($response, JSON_PRETTY_PRINT);
ModelsLab\ModelsLab;
use ModelsLab\Schemas\RealtimeText2ImageSchema;
$apiKey = 'your-api-key';
$modelslab = new ModelsLab($apiKey);
$image = new RealtimeText2ImageSchema([
'prompt' => 'A beautiful landscape',
'width' => 512,
'height' => 512
]);
$response = $modelslab->realtime()->textToImage($image);
echo json_encode($response, JSON_PRETTY_PRINT);
ModelsLab\ModelsLab;
use ModelsLab\Schemas\Text2Video;
$apiKey = 'your-api-key';
$modelslab = new ModelsLab($apiKey);
$video = new Text2Video([
'prompt' => 'A cat playing with a ball',
'model_id' => 'svd'
]);
$response = $modelslab->video()->textToVideo($video);
echo json_encode($response, JSON_PRETTY_PRINT);
ModelsLab\ModelsLab;
use ModelsLab\Schemas\DeepfakeSchema;
$apiKey = 'your-api-key';
$modelslab = new ModelsLab($apiKey);
$deepfake = new DeepfakeSchema([
'init_image' => 'https://example.com/face.jpg',
'init_video' => 'https://example.com/video.mp4',
'output_format' => 'mp4'
]);
$response = $modelslab->deepfake()->singleVideoSwap($deepfake);
echo json_encode($response, JSON_PRETTY_PRINT);
$audio = $modelslab->audio();
// Text to Speech
$response = $audio->textToSpeech($textToSpeechSchema);
// Music Generation
$response = $audio->musicGen($musicGenSchema);
// Voice to Voice
$response = $audio->voice2Voice($voice2VoiceSchema);
// Sound Effects
$response = $audio->sfxGen($sfxSchema);
$video = $modelslab->video();
// Text to Video
$response = $video->textToVideo($videoSchema);
// Image to Video
$response = $video->imageToVideo($imageToVideoSchema);
// Text to Video Ultra
$response = $video->textToVideoUltra($text2VideoUltraSchema);
// Watermark Remover - Remove watermarks from videos
$watermarkRemover = new WatermarkRemoverSchema([
'key' => $apiKey,
'init_video' => 'https://example.com/video.mp4'
]);
$response = $video->watermarkRemover($watermarkRemover);