<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
krisciunaskarolis / openai-images-generator example snippets
use Krisciunas\OpenAi\Api\GenerateImageCommand;
use Krisciunas\OpenAi\Api\ImagePrompt;
$authorizationToken = 'YOUR-OPENAI-API-KEY';
$imagesGenerationCommand = new GenerateImageCommand();
$imagesData = $imagesGenerationCommand->execute(
$authorizationToken,
new ImagePrompt(
'small kitty playing with red fish', //A text description of the desired images. The maximum length is 1000 characters.
4, //Number of images to generate. Must be between 1 and 10
ImagePrompt::SIZE_256x256, // The size of generated images
ImagePrompt::FORMAT_URL //The format in which images are returned
),
);
$imagesPersistor = new ImagesPersist('/PATH/TO/IMAGES/DIRECTORY/');
$imagesPersistor->persist($imagesData, 'FILENAME_FORMAT_%s.png');