| openai {openaistream} | R Documentation |
An R6 Class Interface to OpenAI API
Description
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.
Active bindings
modelsclass
filesclass
fine_tuningclass
chatclass
audioclass
embeddingsclass
imagesclass
moderationsclass
assistantsclass
threadsclass
messagesclass
runsclass
Methods
Public methods
Method new()
Initialize the OpenAI API interface with the provided API key.
Usage
openai$new(api_key)
Arguments
api_keyThe OpenAI API key.
Method set_proxy()
Configure the proxy settings.
Usage
openai$set_proxy(proxy_ip, proxy_port)
Arguments
proxy_ipcharacter Required. The IP address of the proxy.
proxy_portcharacter Required. The port number of the proxy.
Method clone()
The objects of this class are cloneable with this method.
Usage
openai$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
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()
[Package openaistream version 0.3.0 Index]