openai_create_chat_completion {gptstudio}R Documentation

Generate text completions using OpenAI's API for Chat

Description

Generate text completions using OpenAI's API for Chat

Usage

openai_create_chat_completion(
  prompt = "<|endoftext|>",
  model = getOption("gptstudio.model"),
  openai_api_key = Sys.getenv("OPENAI_API_KEY"),
  task = "chat/completions"
)

Arguments

prompt

The prompt for generating completions

model

The model to use for generating text

openai_api_key

The API key for accessing OpenAI's API. By default, the function will try to use the OPENAI_API_KEY environment variable.

task

The task that specifies the API url to use, defaults to "completions" and "chat/completions" is required for ChatGPT model.

Value

A list with the generated completions and other information returned by the API.

Examples

## Not run: 
openai_create_completion(
  model = "text-davinci-002",
  prompt = "Hello world!"
)

## End(Not run)

[Package gptstudio version 0.4.0 Index]