Models

Under the hood, querychat is powered by ellmer, a library for building chat-based applications with large language models (LLMs). ellmer supports a wide range of LLM providers – see here for a full list.

library(querychat)
library(palmerpenguins)
library(ellmer)

Specify a model

To use a particular model, pass a "{provider}/{model}" string to the client parameter, which gets passed along to ellmer::chat():

qc <- querychat(penguins, client = "anthropic/claude-sonnet-4-5")
qc$app()  # Launch the app

And, if you’d like to effectively set a new default model, you can use the querychat.client R option or the QUERYCHAT_CLIENT environment variable.

# In your .Rprofile
options(querychat.client = "anthropic/claude-sonnet-4-5")

Note that it can also be useful to pass a full Chat object to the client parameter for more advanced use cases (e.g., custom parameters, tools, etc):

client <- chat_anthropic(model = "claude-sonnet-4-5")
qc <- querychat(penguins, client = client)
qc$app()  # Launch the app

Credentials

Most models require an API key or some other form of authentication. See the reference page for the relevant model provider (e.g., chat_anthropic()) to learn more on how to set up credentials.

GitHub model marketplace

If you are already setup with GitHub credentials, GitHub model marketplace provides a free and easy way to get started. See here for more details on how to get setup.

library(ellmer)

# Just works if GITHUB_TOKEN is set in your environment
client <- chat_github(model = "gpt-4.1")

In general, most providers will prefer credentials stored as environment variables. Common practice is to use an .Renviron file to manage these variables. For example, for chat_openai(), you might add to your .Renviron file:

OPENAI_API_KEY="your_api_key_here"

Then, you can edit your .Renviron file using:

usethis::edit_r_environ()