% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api.R
\name{call_llm}
\alias{call_llm}
\title{Call the configured LLM}
\usage{
call_llm(prompt, system_prompt, context = NULL)
}
\arguments{
\item{prompt}{Character. The user-facing instruction.}

\item{system_prompt}{Character. The system-level instruction for the model.}

\item{context}{Character or \code{NULL}. Surrounding R code sent as
additional context (prepended to \code{prompt}).}
}
\value{
Character string containing the model's response text.
}
\description{
Unified dispatch function that reads provider, model, and credentials from
options (set via \code{\link[=llmcoder_setup]{llmcoder_setup()}} or \strong{Addins \→ LLMcoder Settings}) and
forwards the request to the appropriate backend.
}
\details{
Supported providers:
\describe{
\item{\code{"openai"}}{OpenAI Chat Completions API
(\verb{https://api.openai.com/v1}).}
\item{\code{"anthropic"}}{Anthropic Messages API
(\verb{https://api.anthropic.com/v1/messages}).}
\item{\code{"deepseek"}}{DeepSeek Chat API, OpenAI-compatible
(\verb{https://api.deepseek.com/v1}).}
\item{\code{"ollama"}}{Local Ollama server (default
\verb{http://localhost:11434}).  No API key required.}
\item{\code{"groq"}}{Groq Cloud API, OpenAI-compatible
(\verb{https://api.groq.com/openai/v1}).  Extremely fast inference.}
\item{\code{"together"}}{Together AI API, OpenAI-compatible
(\verb{https://api.together.xyz/v1}).  Wide open-source model selection.}
\item{\code{"openrouter"}}{OpenRouter API, OpenAI-compatible
(\verb{https://openrouter.ai/api/v1}).  Unified gateway to 100+ models.}
\item{\code{"custom"}}{Any OpenAI-compatible server.  Set
\code{llmcoder.custom_url} to the base URL (e.g.\
\code{"http://localhost:1234/v1"} for LM Studio).}
}
}
\examples{
\dontrun{
llmcoder_setup("ollama", model = "llama3")
resp <- call_llm(
  prompt        = "Write R code to compute the mean of a numeric vector",
  system_prompt = "You are an R programming assistant.",
  context       = NULL
)
cat(resp)
}

}
\keyword{internal}
