powered by
Provides methods to interact with OpenAI API including fetching model details, generating completions, managing files, and more. Always ensure that the API key is kept private.
models
class
files
fine_tuning
chat
audio
embeddings
images
moderations
assistants
threads
messages
runs
openai$new()
openai$set_proxy()
openai$clone()
new()
Initialize the OpenAI API interface with the provided API key.
openai$new(api_key)
api_key
The OpenAI API key.
set_proxy()
Configure the proxy settings.
openai$set_proxy(proxy_ip, proxy_port)
proxy_ip
character Required. The IP address of the proxy.
proxy_port
character Required. The port number of the proxy.
clone()
The objects of this class are cloneable with this method.
openai$clone(deep = FALSE)
deep
Whether to make a deep clone.
# \donttest{ Sys.setenv(OPENAI_KEY="you openai key") aaa <- openai$new(Sys.getenv("OPENAI_KEY")) #if need proxy #aaa$set_proxy("127.0.0.1", 10890) # List model aaa$models$list() # }
Run the code above in your browser using DataLab