powered by
Generate text completions using OpenAI's API for Chat
openai_create_chat_completion( prompt = "<|endoftext|>", model = getOption("gptstudio.model"), openai_api_key = Sys.getenv("OPENAI_API_KEY"), task = "chat/completions" )|endoftext|>
A list with the generated completions and other information returned by the API.
The prompt for generating completions
The model to use for generating text
The API key for accessing OpenAI's API. By default, the function will try to use the OPENAI_API_KEY environment variable.
OPENAI_API_KEY
The task that specifies the API url to use, defaults to "completions" and "chat/completions" is required for ChatGPT model.
if (FALSE) { openai_create_completion( model = "text-davinci-002", prompt = "Hello world!" ) }
Run the code above in your browser using DataLab