openai_cat: Get Category from OpenAI

View source: R/openai_cat.R

openai_catR Documentation

Get Category from OpenAI

Description

Fetches category of content hosted by a domain using OpenAI's chat completion API. The function uses GPT models to classify domains into specified categories.

Usage

openai_cat(
  domains = NULL,
  api_key = NULL,
  categories = NULL,
  model = "gpt-4o-mini",
  rate_limit = 0.5
)

Arguments

domains

vector of domain names

api_key

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

categories

vector of categories to classify into. If NULL, uses default web categories

model

OpenAI model to use (default: "gpt-4o-mini" for cost efficiency)

rate_limit

delay in seconds between API calls (default: 0.5)

Value

data.frame with original list and content category of the domain

Examples

## Not run: 
openai_cat("google.com")
openai_cat(c("google.com", "facebook.com"))
openai_cat("google.com", categories = c("search", "social", "ecommerce", "news", "other"))

## End(Not run)

rdomains documentation built on May 14, 2026, 9:07 a.m.