These are resources available for api in dall-e-2
Images Resource
create
Method : ImagesGenerations::create()
The method may accept the following parameters:
- $prompt: The text description of the image to be generated.
- $apiKey: The API key or token required to access the DALL-E API.
- $model: The name or ID of the DALL-E model to be used for image generation. (Optional)
- $size: The size of the output image in pixels, specified as a width-height tuple. For example, “512×512”. (Optional)
- $n: The number of images to generate for the given text description. Defaults to 1 if not specified. (Optional)
- $response_format: The format of the response, either “json” or “image”. If “json” is selected, the method will return a JSON object containing the URL of the generated image(s). If “image” is selected, the method will download the image(s) to the specified directory. (Optional)
- $response_dir: The directory where the generated image(s) should be saved if the $response_format parameter is set to “image”. (Optional)
$response = $client->images()->create([
'prompt' => 'A cute baby sea otter',
'n' => 1,
'size' => '256x256',
'response_format' => 'url',
]);
parameter
{
"prompt": "A cute baby sea otter",
"n": 2,
"size": "1024x1024"
}
Url=POST https://api.openai.com/v1/images/generations
edit
Creates an edited or extended image given an original image and a prompt.
Method: ImagesEdits::createImage()
The method may accept the following parameters:
- $image_url: The URL of the image to be edited.
- $attributes: An associative array of attribute keys and values that should be modified. For example, array(‘color’ => ‘red’, ‘texture’ => ‘smooth’). The available attributes depend on the DALL-E model being used.
- $apiKey: The API key or token required to access the DALL-E API.
- $model: The name or ID of the DALL-E model to be used for image editing. (Optional)
- $response_format: The format of the response, either “json” or “image”. If “json” is selected, the method will return a JSON object containing the URL of the edited image. If “image” is selected, the method will download the edited image to the specified directory. (Optional)
- $response_dir: The directory where the edited image should be saved if the $response_format parameter is set to “image”. (Optional)
$response = $client->images()->edit([
'image' => fopen('image_edit_original.png', 'r'), // parameter 1
'mask' => fopen('image_edit_mask.png', 'r'), // parameter 2
'prompt' => 'A sunlit indoor lounge area with a pool', // parameter 3
'n' => 1, // parameter 4
'size' => '256x256', // parameter 5
'response_format' => 'url', // parameter 6
]);
$response->created;
foreach ($response->data as $data) {
$data->url;
$data->b64_json;
}
$response->toArray();
Variation
Creates a variation of a given image.
Method : ImagesVariations::createImage()
The method may accept the following parameters:
- $image_url: The URL of the image to be varied.
- $variation_type: The type of variation to be applied to the image. Possible values are “zoom”, “rotate”, “shift”, “color”, “texture”, “pattern”, “jitter”, “brightness”, “contrast”, “saturation”, “noise”, and “blur”.
- $apiKey: The API key or token required to access the DALL-E API.
- $model: The name or ID of the DALL-E model to be used for image variation. (Optional)
- $response_format: The format of the response, either “json” or “image”. If “json” is selected, the method will return a JSON object containing the URL of the generated image(s). If “image” is selected, the method will download the generated image(s) to the specified directory. (Optional)
- $response_dir: The directory where the generated image(s) should be saved if the $response_format parameter is set to “image”. (Optional)
$response = $client->images()->variation([
'image' => fopen('image_edit_original.png', 'r'), //parameter 1
'n' => 1, //parameter 2
'size' => '256x256', //parameter 3
'response_format' => 'url', //parameter 4
]);
url = POST https://api.openai.com/v1/images/variations