PHP code example of arikislam / replicate-php-client

1. Go to this page and download the library: Download arikislam/replicate-php-client 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/ */

    

arikislam / replicate-php-client example snippets


use Arikislam\ReplicatePhpClient\Replicate;

$response = Replicate::createPrediction([
    'input' => [
        'prompt' => 'Test',
        'go_fast' => true,
        'num_outputs' => 1,
        'aspect_ratio' => '16:9',
        'output_format' => 'png',
        'output_quality' => 80,
        'megapixels' => '.25',
    ],
]);

// Get the prediction results
$predictionResult = $response->getResult();

if ($response->isSuccessful()) {
    $output = $response->getResult();
    // Do something with the output, such as saving the image or displaying it
} else {
    // Handle errors
    $errorMessage = $response->getErrorMessage();
    // Log or display the error message
}

use GuzzleHttp\Client;
use Arikislam\ReplicatePhpClient\Replicate;

$client = new Client([
    'base_uri' => 'https://api.replicate.com',
    'timeout'  => 10.0,
]);

$replicate = new Replicate($client);
$response = $replicate->createPrediction([
    // input options
]);
bash
composer 
bash
php artisan vendor:publish --provider="Arikislam\ReplicatePhpClient\Providers\ReplicatePhpClientServiceProvider"