% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{call_llm_api}
\alias{call_llm_api}
\title{Call LLM API (Unified Wrapper)}
\usage{
call_llm_api(
  provider = c("openai", "gemini"),
  system_prompt,
  user_prompt,
  model = NULL,
  temperature = 0,
  max_tokens = 150,
  api_key = NULL
)
}
\arguments{
\item{provider}{Character string: "openai" or "gemini"}

\item{system_prompt}{Character string with system instructions}

\item{user_prompt}{Character string with user message}

\item{model}{Character string specifying the model (provider-specific defaults apply)}

\item{temperature}{Numeric temperature for response randomness (default: 0)}

\item{max_tokens}{Maximum number of tokens to generate (default: 150)}

\item{api_key}{Character string with API key (required for openai/gemini)}
}
\value{
Character string with the model's response
}
\description{
Unified wrapper for calling different LLM providers (OpenAI, Gemini).
Automatically routes to the appropriate provider-specific function.
}
\examples{
if (interactive()) {
# Using OpenAI
response <- call_llm_api(
  provider = "openai",
  system_prompt = "You are a helpful assistant.",
  user_prompt = "Generate a topic label",
  api_key = Sys.getenv("OPENAI_API_KEY")
)

# Using Gemini
response <- call_llm_api(
  provider = "gemini",
  system_prompt = "You are a helpful assistant.",
  user_prompt = "Generate a topic label",
  api_key = Sys.getenv("GEMINI_API_KEY")
)
}
}
\seealso{
\code{\link[=sanitize_llm_input]{sanitize_llm_input()}} to clean text before prompting; \code{\link[=get_best_embeddings]{get_best_embeddings()}} for vector embeddings; \code{\link[=run_rag_search]{run_rag_search()}} for RAG search (retrieval + generation)
}
\concept{ai}
