% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/setup.R
\name{llmcoder_setup}
\alias{llmcoder_setup}
\title{Configure LLMcoder for the current session}
\usage{
llmcoder_setup(
  provider = c("openai", "anthropic", "deepseek", "ollama", "groq", "together",
    "openrouter", "custom"),
  api_key = NULL,
  model = NULL,
  context_lines = 40L,
  ollama_url = "http://localhost:11434",
  custom_url = ""
)
}
\arguments{
\item{provider}{Character.  One of \code{"openai"}, \code{"anthropic"},
\code{"deepseek"}, \code{"ollama"}, \code{"groq"}, \code{"together"}, \code{"openrouter"}, or
\code{"custom"}.}

\item{api_key}{Character.  Your API key.  Not required when
\code{provider = "ollama"}.}

\item{model}{Character.  Model identifier.  If \code{NULL} or \code{""}, a sensible
default is chosen for the provider (see \strong{Details}).}

\item{context_lines}{Integer.  Number of lines of code above the cursor that
are sent as context to the LLM (default \code{40}).  Higher values improve
suggestion quality but increase latency and token cost.}

\item{ollama_url}{Character.  Base URL of the Ollama server (default
\code{"http://localhost:11434"}).  Only used when \code{provider = "ollama"}.}

\item{custom_url}{Character.  Base URL of a custom OpenAI-compatible server
(e.g. \code{"http://localhost:1234/v1"} for LM Studio).  Only used when
\code{provider = "custom"}.}
}
\value{
Invisible \code{NULL}.
}
\description{
Sets the LLM provider, API key, model, and related options for the current R
session.  For \strong{permanent} configuration that survives restarts, use
\strong{Addins > LLMcoder Settings}, which writes to \code{~/.Rprofile}.
}
\details{
\strong{Provider defaults:}\tabular{lll}{
   Provider \tab Default model \tab Notes \cr
   \code{openai} \tab \verb{gpt-4o-mini} \tab Fast, cost-effective \cr
   \code{anthropic} \tab \code{claude-sonnet-4-20250514} \tab Strongest reasoning \cr
   \code{deepseek} \tab \code{deepseek-chat} \tab Very cheap, great code quality \cr
   \code{ollama} \tab \code{llama3} \tab No API key, fully local \cr
   \code{groq} \tab \verb{llama-3.3-70b-versatile} \tab Extremely fast inference \cr
   \code{together} \tab \verb{meta-llama/Llama-3-70b-chat-hf} \tab Large open-source model choice \cr
   \code{openrouter} \tab \verb{openai/gpt-4o-mini} \tab Unified gateway for 100+ models \cr
   \code{custom} \tab \code{""} (must specify) \tab Any OpenAI-compat endpoint \cr
}
}
\examples{
\dontrun{
# OpenAI
llmcoder_setup("openai", api_key = Sys.getenv("OPENAI_API_KEY"))
llmcoder_setup("openai", api_key = Sys.getenv("OPENAI_API_KEY"), model = "gpt-4o")

# Anthropic Claude
llmcoder_setup("anthropic", api_key = Sys.getenv("ANTHROPIC_API_KEY"))

# DeepSeek (cheapest, excellent code quality)
llmcoder_setup("deepseek", api_key = Sys.getenv("DEEPSEEK_API_KEY"))

# Ollama — fully local, no API key needed
llmcoder_setup("ollama", model = "qwen2.5-coder:7b")
llmcoder_setup("ollama", model = "codellama:13b",
               ollama_url = "http://192.168.1.10:11434")  # remote server

# Groq — extremely fast inference on open models
llmcoder_setup("groq",
  api_key = Sys.getenv("GROQ_API_KEY"),
  model   = "llama-3.3-70b-versatile")

# Together AI — wide open-source model selection
llmcoder_setup("together",
  api_key = Sys.getenv("TOGETHER_API_KEY"),
  model   = "mistralai/Mixtral-8x7B-Instruct-v0.1")

# OpenRouter — unified gateway, supports 100+ models
llmcoder_setup("openrouter",
  api_key = Sys.getenv("OPENROUTER_API_KEY"),
  model   = "anthropic/claude-3.5-sonnet")

# LM Studio or any OpenAI-compatible local server
llmcoder_setup("custom",
  api_key    = "lm-studio",
  model      = "local-model",
  custom_url = "http://localhost:1234/v1")

# Reduce context window to save tokens
llmcoder_setup("openai",
  api_key       = Sys.getenv("OPENAI_API_KEY"),
  context_lines = 20L)
}

}
\seealso{
\code{\link[=llmcoder_config]{llmcoder_config()}}, \code{\link[=addin_settings]{addin_settings()}}
}
