if (FALSE) {
library(openaiRtools)
client <- OpenAI$new(api_key = "sk-xxxxxx")
# Build an image part from a URL
img <- image_from_url(
url = "https://example.com/photo.jpg",
detail = "low"
)
# Assemble a message manually
messages <- list(
list(
role = "user",
content = list(
list(type = "text", text = "What painting is this?"),
img
)
)
)
response <- client$chat$completions$create(
messages = messages,
model = "gpt-4o"
)
cat(response$choices[[1]]$message$content)
}
Run the code above in your browser using DataLab