Tidy Integration of Large Language Models

A tidy interface for integrating large language model (LLM) APIs such as 'Claude', 'OpenAI', 'Gemini', 'Mistral', and local models via 'Ollama' into R workflows. The package supports text, image, audio, video, and document interactions; a unified media interface for attaching inline files or uploading to provider file stores; batch request APIs for cost-efficient large-scale processing; and a pipeline-oriented interface for seamless integration into data workflows. Web services are available at < https://www.anthropic.com>, < https://openai.com>, < https://aistudio.google.com/>, < https://mistral.ai/> and < https://ollama.com>.


tidyllm tidyllm website

License: MIT CRAN Status

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.

Features

  • Multiple providers: Switch between cloud and local models using the same verb + provider pattern.
  • Unified media system: Send images, audio, video, and PDFs to any provider that supports them via .media. Upload files to provider servers for reuse via .files and upload_file().
  • Interactive message history: Manage multi-turn conversations with structured history automatically formatted for each API.
  • Batch processing: Handle large workloads with Anthropic, OpenAI, Mistral, Groq, and Gemini batch APIs, reducing costs by up to 50%.
  • Tidy workflow: Pipeline-oriented, side-effect-free design that integrates naturally with tidyverse data workflows.

Installation

To install tidyllm from CRAN, use:

install.packages("tidyllm")

Or for the development version from GitHub:

devtools::install_github("edubruell/tidyllm")

Basic Example

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.

What's new in 0.7.1

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.

Learn More

Similar packages

  • ellmer keeps conversation state in objects and concentrates on chat providers, which suits interactive agents, chatbots in Shiny and tool-calling workflows. tidyllm keeps its verbs as stateless as possible, so they fit data pipelines and batch work, and it covers API features beyond chat, such as batch jobs, embeddings, file uploads and web search. The two packages work together: chat(ellmer(.ellmer_chat = ...)) runs a tidyllm message through any ellmer chat object.
  • rollama is purpose-built for the Ollama API with specialized model management features not currently in tidyllm.

Contributing

Contributions are welcome. Open an issue or a pull request on GitHub.

License

This project is licensed under the MIT License; see the LICENSE file for details.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("tidyllm")

0.7.1 by Eduard Brüll, 8 days ago


https://edubruell.github.io/tidyllm/


Report a bug at https://github.com/edubruell/tidyllm/issues


Browse source code at https://github.com/cran/tidyllm


Authors: Eduard Brüll [aut, cre] , Jia Zhang [ctb]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports S7, base64enc, glue, jsonlite, coro, curl, httr2, lubridate, purrr, rlang, stringr, grDevices, pdftools, tibble, cli, png, lifecycle

Suggests later, processx, shiny, wooldridge, promises, knitr, rmarkdown, testthat, tidyverse, httptest2, httpuv, withr, ellmer


Suggested by RKorAPClient, joinery.


See at CRAN