Learn R Programming

openaistream (version 0.2.0)

openai: 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.

Arguments

Active bindings

models

class

files

class

fine_tuning

class

chat

class

audio

class

embeddings

class

images

class

moderations

class

assistants

class

threads

class

messages

class

runs

class

Methods


Method new()

Initialize the OpenAI API interface with the provided API key.

Usage

openai$new(api_key)

Arguments

api_key

The OpenAI API key.


Method set_proxy()

Configure the proxy settings.

Usage

openai$set_proxy(proxy_ip, proxy_port)

Arguments

proxy_ip

character Required. The IP address of the proxy.

proxy_port

character 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

deep

Whether to make a deep clone.

Examples

Run this code
# \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