PHP code example of runapi-ai / gpt-image
1. Go to this page and download the library: Download runapi-ai/gpt-image 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 / gpt-image example snippets
unApi\GptImage\GptImageClient;
$client = new GptImageClient(); // reads RUNAPI_API_KEY
$task = $client->textToImage->create([
'model' => 'gpt-image-1.5',
'prompt' => 'A precise product render on white marble',
'aspect_ratio' => '1:1',
'quality' => 'medium',
]);
$status = $client->textToImage->get($task->id);
$result = $client->textToImage->run([
'model' => 'gpt-image-1.5',
'prompt' => 'A serene mountain lake at dawn',
'aspect_ratio' => '3:2',
'quality' => 'high',
]);
echo $result->images[0]->url . PHP_EOL;