PHP code example of runapi-ai / recraft
1. Go to this page and download the library: Download runapi-ai/recraft 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 / recraft example snippets
unApi\Recraft\RecraftClient;
$client = new RecraftClient(); // reads RUNAPI_API_KEY
$removeBackgroundTask = $client->removeBackground->create([
'model' => 'recraft-remove-background',
'source_image_url' => 'https://cdn.runapi.ai/public/samples/image.jpg',
]);
$task = $client->upscaleImage->create([
'model' => 'recraft-crisp-upscale',
'source_image_url' => 'https://cdn.runapi.ai/public/samples/image.jpg',
]);
$status = $client->upscaleImage->get($task->id);
$result = $client->upscaleImage->run([
'model' => 'recraft-crisp-upscale',
'source_image_url' => 'https://cdn.runapi.ai/public/samples/image.jpg',
]);
echo $result->images[0]->url . PHP_EOL;