Learn R Programming

openaiRtools (version 0.2.2)

create_image_edit: Edit an Image with DALL-E (Convenience Function)

Description

Shortcut that creates an OpenAI client from the OPENAI_API_KEY environment variable and calls client$images$edit(). Edits a local PNG image based on a text prompt and optional mask.

Usage

create_image_edit(image, prompt, mask = NULL, ...)

Value

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

Arguments

image

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

prompt

Character. Required. Description of the desired edit.

mask

Character or NULL. Path to a mask PNG. Transparent pixels indicate which region to edit. Default: NULL (entire image).

...

Additional parameters passed to ImagesClient$edit(), such as n (number of images), size, response_format, user.

Examples

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

resp <- create_image_edit(
  image  = "photo.png",
  prompt = "Add a mountain range in the background",
  mask   = "sky_mask.png"
)
cat(resp$data[[1]]$url)
}

Run the code above in your browser using DataLab