% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/topic_modeling.R
\name{generate_topic_labels}
\alias{generate_topic_labels}
\title{Generate Topic Labels Using AI}
\usage{
generate_topic_labels(
  top_topic_terms,
  provider = "auto",
  model = NULL,
  system = NULL,
  user = NULL,
  temperature = 0.5,
  api_key = NULL,
  openai_api_key = NULL,
  verbose = TRUE
)
}
\arguments{
\item{top_topic_terms}{A data frame containing the top terms for each topic.}

\item{provider}{AI provider to use: "auto" (default), "openai", or "gemini".
"auto" picks the first provider with an available API key.}

\item{model}{A character string specifying which model to use. If NULL, uses
provider defaults: "gpt-4.1-mini" (OpenAI), "gemini-2.5-flash-lite" (Gemini).}

\item{system}{A character string containing the system prompt for the API.
If NULL, the function uses the default system prompt.}

\item{user}{A character string containing the user prompt for the API.
If NULL, the function uses the default user prompt.}

\item{temperature}{A numeric value controlling the randomness of the output (default: 0.5).}

\item{api_key}{API key for OpenAI or Gemini. If NULL, uses environment variable.}

\item{openai_api_key}{Deprecated. Use \code{api_key} instead. Kept for backward compatibility.}

\item{verbose}{Logical, if TRUE, prints progress messages.}
}
\value{
A data frame containing the top terms for each topic along with their generated labels.
}
\description{
This function generates descriptive labels for each topic based on their
top terms using AI providers (OpenAI or Gemini).
}
\examples{
if (interactive()) {
top_topic_terms <- get_topic_terms(stm_model, top_term_n = 10)

# Auto-detect provider (tries OpenAI -> Gemini)
labels <- generate_topic_labels(top_topic_terms)

# Use specific provider
labels_openai <- generate_topic_labels(top_topic_terms, provider = "openai")
labels_gemini <- generate_topic_labels(top_topic_terms, provider = "gemini")
}
}
\seealso{
\code{\link[=get_topic_terms]{get_topic_terms()}} to extract top terms first; \code{\link[=generate_topic_content]{generate_topic_content()}} for survey items / RQs / themes grounded in the same terms; \code{\link[=call_llm_api]{call_llm_api()}} for the direct AI provider call
}
\concept{topic-modeling}
