Learn R Programming

tidyllm

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, Perplexity, 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.5.0

Unified media and files system. All non-text content now attaches to messages, not to chat() call arguments:

# Inline binary — works with any provider that supports the type
llm_message("Transcribe this audio.", .media = audio_file("recording.mp3")) |>
  chat(gemini())

llm_message("Summarize this paper.", .media = pdf_file("paper.pdf")) |>
  chat(claude())

# Multiple images in one message
llm_message("Compare these two charts.",
            .media = list(img("chart_a.png"), img("chart_b.png"))) |>
  chat(openai())

# Provider Files API — upload once, reuse across requests
report <- upload_file(claude(), .path = "annual_report.pdf")
llm_message("What are the key risks?", .files = report) |>
  chat(claude())

Audio and video are supported by Gemini, OpenRouter (Gemini, Gemma 4, Qwen 3.6, and other models), Mistral (Voxtral), and llama.cpp (Ultravox, Gemma 4, Qwen2.5-Omni). The .imagefile and old provider-specific upload functions still work but now emit deprecation warnings.

OpenAI now uses the Responses API (POST /v1/responses) with reasoning effort control, built-in web search, and background deep research:

llm_message("What are the latest developments in fusion energy?") |>
  chat(openai(), .tools = openai_websearch())

llm_message("Write a detailed report on EU AI regulation.") |>
  deep_research(openai())

Read the Changelog for the full list of changes.

Learn More

Similar packages

  • ellmer is especially well-suited for asynchronous chats, chatbots in Shiny, and advanced tool-calling workflows. Its design philosophy differs from tidyllm: ellmer targets interactive agents while tidyllm targets data pipelines and batch operations.
  • rollama is purpose-built for the Ollama API with specialized model management features not currently in tidyllm.

Contributing

We welcome contributions! Feel free to open issues or submit pull requests on GitHub.

License

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

Copy Link

Version

Install

install.packages('tidyllm')

Monthly Downloads

718

Version

0.5.1

License

MIT + file LICENSE

Maintainer

Eduard Brüll

Last Published

July 23rd, 2026

Functions in tidyllm (0.5.1)

check_batch

Check Batch Processing Status
deep_research

Run Deep Research via a Provider
df_llm_message

Convert a Data Frame to an LLMMessage Object
claude_delete_file

Delete a File from Claude API
ellmer

Alias for the Ellmer Provider Function
claude_list_files

List Files in Claude API
claude_file_metadata

Retrieve Metadata for a File from Claude API
fetch_job

Fetch Results from a Batch or Research Job
claude_list_models

List Available Models from the Anthropic Claude API
fetch_groq_batch

Fetch Results for a Groq Batch
deepseek

Deepseek Provider Function
embed

Generate text embeddings
fetch_mistral_batch

Fetch Results for an Mistral Batch
claude_websearch

Builtin Claude Web Search Tool
gemini_embedding

Generate Embeddings Using the Google Gemini API
ellmer_tool

Convert an ellmer Tool to a tidyllm TOOL
gemini_file_metadata

Retrieve Metadata for a File from Gemini API
fetch_batch

Fetch Results from a Batch API
claude_upload_file

Upload a File to Claude API
fetch_azure_openai_batch

Fetch Results for an Azure OpenAI Batch
field_chr

Define Field Descriptors for JSON Schema
fetch_openai_batch

Fetch Results for an OpenAI Batch
deepseek_chat

Send LLM Messages to the DeepSeek Chat API
get_user_message

Retrieve a User Message by Index
get_reply_data

Retrieve Assistant Reply as Structured Data
groq

Groq API Provider Function
field_object

Define a nested object field
groq_chat

Send LLM Messages to the Groq Chat API
gemini

Google Gemini Provider Function
file_info

Get Metadata for a File Stored on a Provider
delete_file

Delete a File from a Provider's File Store
fetch_gemini_batch

Fetch Results for a Gemini Batch
fetch_claude_batch

Fetch Results for a Claude Batch
get_metadata

Retrieve Metadata from Assistant Replies
gemini_upload_file

Upload a File to Gemini API
get_logprobs

Retrieve Log Probabilities from Assistant Replies
img

Create an Image Object
get_reply

Retrieve Assistant Reply as Text
list_gemini_batches

List Recent Gemini Batch Operations
gemini_chat

Send LLMMessage to Gemini API
list_groq_batches

List Groq Batch Requests
gemini_delete_file

Delete a File from Gemini API
list_files

List Files Stored on a Provider
llamacpp_health

Check Health of the llama.cpp Server
gemini_list_files

List Files in Gemini API
list_claude_batches

List Claude Batch Requests
llamacpp_delete_model

Delete a Local GGUF Model File
list_batches

List all Batch Requests on a Batch API
llamacpp_chat

Send LLM Messages to a llama.cpp Server
gemini_list_models

List Available Models from the Google Gemini API
llamacpp_list_local_models

List Local GGUF Model Files
list_models

List Available Models for a Provider
groq_transcribe

Transcribe an Audio File Using Groq transcription API
groq_list_models

List Available Models from the Groq API
list_hf_gguf_files

List GGUF Files Available in a Hugging Face Repository
llamacpp_download_model

Download a GGUF Model from Hugging Face
ollama_delete_model

Delete a model from the Ollama API
ollama_chat

Interact with local AI models via the Ollama API
mistral_list_models

List Available Models from the Mistral API
llamacpp_embedding

Generate Embeddings Using a llama.cpp Server
openai_chat

Send LLM Messages to the OpenAI Responses API
llamacpp_rerank

Rerank Documents Using a llama.cpp Server
llamacpp_list_models

List Models Loaded in the llama.cpp Server
list_mistral_batches

List Mistral Batch Requests
llamacpp

llama.cpp Provider Function
openai_code_interpreter

OpenAI built-in code interpreter tool (server-executed)
openai_check_research

Check the Status of an OpenAI Background Research Job
list_openai_batches

List OpenAI Batch Requests
ollama

Ollama API Provider Function
llm_message

Create or Update Large Language Model Message Object
mistral

Mistral Provider Function
openai_deep_research

Submit a Deep Research Request to OpenAI
openai_websearch

OpenAI built-in web search tool (server-executed)
openai_list_models

List Available Models from the OpenAI API
openrouter_embedding

Generate Embeddings Using the OpenRouter API
openrouter_credits

Get OpenRouter Credit Balance
openai_embedding

Generate Embeddings Using OpenAI API
list_azure_openai_batches

List Azure OpenAI Batch Requests
mistral_chat

Send LLMMessage to Mistral API
ollama_list_models

Retrieve and return model information from the Ollama API
openrouter_generation

Get Details for an OpenRouter Generation
openai

OpenAI Provider Function
openrouter_list_models

List Available Models on OpenRouter
perplexity_fetch_research

Fetch Results from a Completed Perplexity Deep Research Job
rate_limit_info

Get the current rate limit information for all or a specific API
perplexity

Perplexity Provider Function
pdf_page_batch

Batch Process PDF into LLM Messages
openai_fetch_research

Fetch Results from a Completed OpenAI Deep Research Job
mistral_embedding

Generate Embeddings Using Mistral API
tidyllm_schema

Create a JSON Schema for Structured Outputs
send_gemini_batch

Submit a list of LLMMessage objects to Gemini's batch API
send_claude_batch

Send a Batch of Messages to Claude API
tidyllm-package

tidyllm: Tidy Integration of Large Language Models
video_file

Create a Video Object
voyage

Voyage Provider Function
perplexity_deep_research

Submit a Deep Research Request to Perplexity
send_mistral_batch

Send a Batch of Requests to the Mistral API
perplexity_check_research

Check the Status of a Perplexity Deep Research Job
send_groq_batch

Send a Batch of Messages to the Groq API
voyage_rerank

Rerank Documents Using Voyage AI API
voyage_embedding

Generate Embeddings Using Voyage AI API
upload_file

Upload a File to a Provider's File Store
openrouter_chat

Send LLM Messages to the OpenRouter Chat API
openrouter

OpenRouter Provider Function
ollama_embedding

Generate Embeddings Using Ollama API
ollama_download_model

Download a model from the Ollama API
send_ollama_batch

Send a Batch of Messages to Ollama API
pdf_file

Create a PDF Object
send_openai_batch

Send a Batch of Messages to OpenAI Batch API
perplexity_chat

Send LLM Messages to the Perplexity Chat API
send_azure_openai_batch

Send a Batch of Messages to Azure OpenAI Batch API
send_batch

Send a batch of messages to a batch API
tidyllm_tool

Create a Tool Definition for tidyllm
azure_openai

Azure OpenAI Endpoint Provider Function
chat_completions_chat

Chat with any OpenAI-Compatible API Endpoint
chat

Chat with a Language Model
chat_ellmer

Send LLM Messages to Ellmer Chat Object
audio_file

Create an Audio Object
cancel_openai_batch

Cancel an In-Progress OpenAI Batch
LLMMessage

Large Language Model Message Class
azure_openai_embedding

Generate Embeddings Using OpenAI API on Azure
chatgpt

Alias for the OpenAI Provider Function
azure_openai_chat

Send LLM Messages to an Azure OpenAI Chat Completions endpoint
check_openai_batch

Check Batch Processing Status for OpenAI Batch API
check_mistral_batch

Check Batch Processing Status for Mistral Batch API
claude_chat

Interact with Claude AI models via the Anthropic API
claude

Provider Function for Claude models on the Anthropic API
check_azure_openai_batch

Check Batch Processing Status for Azure OpenAI Batch API
check_claude_batch

Check Batch Processing Status for Claude API
check_job

Check the Status of a Batch or Research Job
check_groq_batch

Check Batch Processing Status for Groq API
check_gemini_batch

Check the Status of a Gemini Batch Operation