Learn R Programming

openaiRtools (version 0.2.2)

list_models: List Available Models (Convenience Function)

Description

Shortcut that creates an OpenAI client from the OPENAI_API_KEY environment variable and returns all models available to your API key.

Usage

list_models()

Arguments

Value

A list with $data — a list of model objects, each containing $id (model name string), $owned_by, and $created (Unix timestamp).

Examples

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

models <- list_models()

# Extract all model IDs as a character vector
model_ids <- sapply(models$data, `[[`, "id")
cat(model_ids, sep = "\n")

# Find all embedding models
embed_models <- model_ids[grepl("embedding", model_ids)]
cat(embed_models, sep = "\n")
}

Run the code above in your browser using DataLab