Learn R Programming

openaiRtools (version 0.2.2)

create_image_variation: Create Image Variations with DALL-E (Convenience Function)

Description

Shortcut that creates an OpenAI client from the OPENAI_API_KEY environment variable and calls client$images$create_variation(). Generates one or more variations of an existing image.

Usage

create_image_variation(image, model = "dall-e-2", ...)

Value

A list with $data containing the generated variation image(s). Access the URL via $data[[1]]$url.

Arguments

image

Character. Required. Path to the local square PNG image (less than 4 MB).

model

Character. Currently only "dall-e-2" is supported. Default: "dall-e-2".

...

Additional parameters passed to ImagesClient$create_variation(), such as n (number of variations, 1–10), size, response_format.

Examples

Run this code
if (FALSE) {
Sys.setenv(OPENAI_API_KEY = "sk-xxxxxx")

# Generate 2 variations of your logo
resp <- create_image_variation(
  image = "logo.png",
  n     = 2,
  size  = "512x512"
)
cat(resp$data[[1]]$url)
cat(resp$data[[2]]$url)
}

Run the code above in your browser using DataLab