Closed ManuelSpinola closed 1 year ago
There are basically two ways:
1/ Via URL (recommended):
library(openai)
response <- create_image(
prompt = "An astronaut riding a horse in a photorealistic style",
n = 1,
size = "256x256",
response_format = "url"
)
# copy and paste the following link in your browser
response$data$url
# or display in R Viewer
library(magick)
astronaut <- image_read(response$data$url)
print(astronaut)
2/ Via Base64 encoding:
response <- create_image(
prompt = "An astronaut riding a horse in a photorealistic style",
size = "256x256",
response_format = "b64_json"
)
image <- jsonlite::base64_dec(response$data$b64_json) %>%
png::readPNG()
grid::grid.raster(image)
Thank you very much. Very helpful.
How can I see the image created by create_image?