Learn R Programming

openaiRtools (version 0.2.2)

create_assistant: Create an Assistant (Convenience Function)

Description

Shortcut that creates an OpenAI client from the OPENAI_API_KEY environment variable and calls client$assistants$create().

Usage

create_assistant(model, ...)

Value

An assistant object with $id (save this for future use), $name, $model, $instructions, and $tools.

Arguments

model

Character. Required. Model ID to power the assistant (e.g. "gpt-4o", "gpt-4o-mini").

...

Additional parameters passed to AssistantsClient$create(): name, description, instructions, tools, tool_resources, metadata, temperature, top_p, response_format.

Examples

Run this code
if (FALSE) {
Sys.setenv(OPENAI_API_KEY = "sk-xxxxxx")

asst <- create_assistant(
  model        = "gpt-4o",
  name         = "Stats Helper",
  instructions = "You help with statistical analysis in R and Python.",
  tools        = list(list(type = "code_interpreter"))
)
cat("Created assistant ID:", asst$id)
}

Run the code above in your browser using DataLab