% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/provider-lmstudio.R
\name{chat_lmstudio}
\alias{chat_lmstudio}
\alias{models_lmstudio}
\title{Chat with a local LM Studio model}
\usage{
chat_lmstudio(
  system_prompt = NULL,
  base_url = Sys.getenv("LMSTUDIO_BASE_URL", "http://localhost:1234"),
  model,
  params = NULL,
  api_args = list(),
  echo = NULL,
  credentials = NULL,
  api_headers = character()
)

models_lmstudio(base_url = "http://localhost:1234", credentials = NULL)
}
\arguments{
\item{system_prompt}{A system prompt to set the behavior of the assistant.}

\item{base_url}{The base URL to the API endpoint.}

\item{model}{The model to use for the chat.
Use \code{models_lmstudio()} to see all options.}

\item{params}{Common model parameters, usually created by \code{\link[=params]{params()}}.}

\item{api_args}{Named list of arbitrary extra arguments appended to the body
of every chat API call. Combined with the body object generated by ellmer
with \code{\link[=modifyList]{modifyList()}}.}

\item{echo}{One of the following options:
\itemize{
\item \code{none}: don't emit any output (default when running in a function).
\item \code{output}: echo text and tool-calling output as it streams in (default
when running at the console).
\item \code{all}: echo all input and output.
}

Note this only affects the \code{chat()} method.}

\item{credentials}{LM Studio doesn't require credentials for local usage
and in most cases you do not need to provide \code{credentials}.

However, if you're accessing an LM Studio instance hosted behind a
reverse proxy or secured endpoint that enforces bearer-token
authentication, you can set the \code{LMSTUDIO_API_KEY} environment variable
or provide a callback function to \code{credentials}.}

\item{api_headers}{Named character vector of arbitrary extra headers appended
to every chat API call.}
}
\value{
A \link{Chat} object.
}
\description{
\ifelse{html}{\figure{support-community.svg}{options: alt='[Community supported provider]'}}{\strong{[Community supported provider]}}

To use \code{chat_lmstudio()} first download and install
\href{https://lmstudio.ai}{LM Studio}. Then load a model using the LM Studio
GUI and start the local server. To learn more about running LM Studio
locally, see \url{https://lmstudio.ai/docs/developer/core/server}/.

Built on top of \code{\link[=chat_openai_compatible]{chat_openai_compatible()}}.
}
\examples{
\dontrun{
# https://lmstudio.ai/models/zai-org/glm-4.7-flash
chat <- chat_lmstudio(model = "zai-org/glm-4.7-flash")
chat$chat("Tell me three jokes about statisticians")
}

}
\seealso{
Other chatbots:
\code{\link[=chat_anthropic]{chat_anthropic()}},
\code{\link[=chat_aws_bedrock]{chat_aws_bedrock()}},
\code{\link[=chat_azure_openai]{chat_azure_openai()}},
\code{\link[=chat_cloudflare]{chat_cloudflare()}},
\code{\link[=chat_databricks]{chat_databricks()}},
\code{\link[=chat_deepseek]{chat_deepseek()}},
\code{\link[=chat_github]{chat_github()}},
\code{\link[=chat_google_gemini]{chat_google_gemini()}},
\code{\link[=chat_groq]{chat_groq()}},
\code{\link[=chat_huggingface]{chat_huggingface()}},
\code{\link[=chat_mistral]{chat_mistral()}},
\code{\link[=chat_ollama]{chat_ollama()}},
\code{\link[=chat_openai]{chat_openai()}},
\code{\link[=chat_openai_compatible]{chat_openai_compatible()}},
\code{\link[=chat_openrouter]{chat_openrouter()}},
\code{\link[=chat_perplexity]{chat_perplexity()}},
\code{\link[=chat_portkey]{chat_portkey()}},
\code{\link[=chat_posit]{chat_posit()}}
}
\concept{chatbots}
