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