Sends each distinct domain name to the model behind chat and constrains the reply
to one of categories through the provider's structured-output API, so the answer
is always in the requested vocabulary or recorded as a failure. Any provider that
ellmer supports works: OpenAI, Anthropic, Google Gemini, Ollama, AWS Bedrock and
others. No page content is fetched; the answer reflects the model's knowledge of the
name, not a verified observation of the current website. openai_cat() and
claude_cat() are thin wrappers that build the chat for you.
llm_cat(
domains,
chat,
categories = NULL,
mode = c("batch", "parallel", "sequential"),
state_file = NULL,
max_active = 10,
rpm = 500,
wait = TRUE
)character vector of domain names or URLs
an ellmer chat object, for example
ellmer::chat_openai(model = "gpt-6-luna")
vector of categories to classify into. If NULL, uses
web_categories()
one of "batch" (default), "parallel" or "sequential"
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.
maximum simultaneous requests in parallel mode
requests per minute allowed in parallel mode
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.
A tibble following classification_results. provider is ellmer's provider
name in lower case, model_id the requested model. details holds the category
vocabulary, the mode, the state file, per-request token counts and ellmer's cost
estimate. http_status is NA because ellmer does not expose the response of a
successful request.
The default, mode = "batch", submits every prompt to the provider's batch API
(OpenAI, Anthropic, Google Gemini and Groq): roughly half the price, results within
24 hours and usually much sooner, and a job that survives interruption because
state_file records it. When state_file is NULL the file is named from a hash of
the provider, model and prompts under rdomains_cache_dir(), so
calling again with the same arguments resumes or collects the job instead of paying
twice; the path is reported in details and in a message. Providers without a batch
API are refused rather than emulated; pass mode = "parallel" for them.
"parallel" keeps up to max_active requests in flight under a ceiling of rpm
requests per minute and answers in seconds. "sequential" sends one request at a
time. In every mode ellmer retries transient failures (HTTP 429 and 503) up to three
times before a row is reported as failed.
if (FALSE) { # \dontrun{
chat <- ellmer::chat_openai(model = "gpt-6-luna")
llm_cat(domains, chat) # batch job, resumable
llm_cat(domains, chat, state_file = "domains-batch.json", wait = FALSE)
llm_cat(c("nytimes.com", "amazon.com"), chat, mode = "parallel")
} # }