Infers a category from the domain name with an OpenAI model through llm_cat(). No page content is fetched. The answer reflects the provider's knowledge and the domain name, not a verified observation of the current website.

openai_cat(
  domains,
  api_key = NULL,
  categories = NULL,
  model = "gpt-6-luna",
  mode = c("batch", "parallel", "sequential"),
  state_file = NULL,
  max_active = 10,
  rpm = 500,
  wait = TRUE,
  base_url = NULL
)

Arguments

domains

character vector of domain names or URLs

api_key

OpenAI API key. If not provided, looks for the OPENAI_API_KEY environment variable

categories

vector of categories to classify into. If NULL, uses web_categories()

model

OpenAI model to use (default: "gpt-6-luna" for cost efficiency)

mode

one of "batch" (default), "parallel" or "sequential"

state_file

batch mode only: path of a .json file that records the job. NULL derives one from the provider, model and prompts under the user cache directory. Not allowed in the other modes.

max_active

maximum simultaneous requests in parallel mode

rpm

requests per minute allowed in parallel mode

wait

batch mode only: wait for the job to complete (TRUE) or return at once. Rows whose results are not yet available carry error_code = "batch_pending" and are retryable; call again with the same state_file to collect them.

base_url

API endpoint; NULL uses OpenAI's. Set it for an OpenAI-compatible gateway.

Value

A tibble following classification_results, including provider failures and model identity.

See also

llm_cat() for any ellmer provider and the parallel and batch modes.

Examples

if (FALSE) { # \dontrun{
openai_cat(domains) # batch job, about half price, resumable
openai_cat(domains, state_file = "openai-batch.json", wait = FALSE)
openai_cat(c("google.com", "facebook.com"), mode = "parallel")
openai_cat("google.com", categories = c("search", "social", "ecommerce", "news", "other"))
} # }