
tidyllm is an R package for working with large language model APIs in data analysis workflows. It supports Anthropic Claude, OpenAI, Google Gemini, Mistral, Groq, DeepSeek, OpenRouter, local models via Ollama and llama.cpp, and more, all through a single consistent interface.
.media.
Upload files to provider servers for reuse via .files and
upload_file().To install tidyllm from CRAN, use:
install.packages("tidyllm")Or for the development version from GitHub:
devtools::install_github("edubruell/tidyllm")library(tidyllm)
# Describe an image with Claude, continue with a local model
conversation <- llm_message("Describe this image.",
.media = img("photo.jpg")) |>
chat(claude())
conversation |>
llm_message("Based on that description, what research topic could this figure relate to?") |>
chat(ollama(.model = "qwen3.5:4b"))For more examples and advanced usage, see the Get Started vignette.
Please note: To use tidyllm you need either a local Ollama or llama.cpp installation, or an active API key for one of the supported cloud providers. See the Get Started vignette for setup instructions.
Use your coding agent from R.
codex_cli() runs OpenAI’s Codex CLI and
vibe_cli() runs Mistral’s Vibe CLI, both on your own
machine, the same way claude_cli() runs Claude Code:
llm_message("Explain what a tibble is in one sentence.") |>
chat(codex_cli())
llm_message("Explain what a tibble is in one sentence.") |>
chat(vibe_cli(.model = "mistral-large-4"))Control Gemini reasoning by level.
gemini() takes .thinking_level
("minimal", "low", "medium" or
"high"). Google is replacing token budgets with these
levels, so .thinking_budget now warns that it is
deprecated.
llm_message("What is 17 * 23?") |>
chat(gemini(.thinking_level = "high"))Mistral Large 4. mistral() works with
mistral-large-4, a reasoning model with a 512K-token
context. Set .reasoning_effort = "none" to turn its
reasoning off.
Fix for claude_cli(). With its tools
off, claude_cli() could still read files. It no longer
does. The 0.7.0 release on CRAN has the same leak.
Read the Changelog for the full list of changes.
chat(ellmer(.ellmer_chat = ...)) runs a
tidyllm message through any ellmer chat object.Contributions are welcome. Open an issue or a pull request on GitHub.
This project is licensed under the MIT License; see the LICENSE file for details.