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, DeepSeek, OpenRouter, TypeSafe (decision models), 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().
  • Closed questions with probabilities: decide() puts yes/no, choice and score questions to a text or an image and returns a tibble with one row per question and the probability of each answer. It works with jev(), openai(), gemini() and ollama().
  • 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.8.0

Closed questions with probabilities. decide() puts yes/no, choice and score questions to a text, an image, a recording or a PDF. It returns a tibble with one row per question, the answer and its probability. You write the questions once as a tidyllm_schema() and switch between jev(), openai(), gemini() and ollama().

questions <- tidyllm_schema(
  late = field_lgl("Was the payment late?"),
  tone = field_fct("Tone of the message", .levels = c("polite", "angry"))
)

decide("Your invoice is two weeks overdue and I am furious.", questions, jev())

Pass a character vector to code many texts in parallel. field_box() asks where something is in a picture (experimental, jev() only). The decision models article walks through it.

Read many replies at once. get_reply(), get_reply_data() and get_metadata() accept the list that parallel_chat() and fetch_batch() return.

Current provider defaults. mistral() defaults to mistral-large-4, which always reasons (.reasoning_effort of "low", "medium" or "high"). openai() accepts every reasoning effort the API names, and gemini() accepts .thinking_level = "xhigh". llamacpp() looks for the server on port 9931.

Perplexity removed. perplexity() is gone. Use Perplexity models through openrouter() and web search through websearch_tool().

Read the Changelog for the full list of changes.

Learn More

Get Started with tidyllm covers setup, your first chat and the basic verbs. Read it first, then pick the article that matches your task. The Changelog lists every change, and the documentation holds the function reference.

Start here: the common research tasks, simplest first

Go deeper: setup choices and larger builds

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.

Copy Link

Version

Install

install.packages('tidyllm')

Monthly Downloads

1,203

Version

0.8.0

License

MIT + file LICENSE

Maintainer

Eduard Brüll

Last Published

November 16th, 2026

Functions in tidyllm (0.8.0)

claude_upload_file

Upload a File to Claude API
claude_delete_file

Delete a File from Claude API
claude

Provider Function for Claude models on the Anthropic API
check_job

Check the Status of a Job
claude_chat

Interact with Claude AI models via the Anthropic API
claude_cli

Chat through a locally installed Claude CLI
claude_cli_chat

Chat with Claude through your own installed Claude CLI
delete_file

Delete a File from a Provider's File Store
ellmer

Alias for the Ellmer Provider Function
df_llm_message

Convert a Data Frame to an LLMMessage Object
ellmer_tool

Convert an ellmer Tool to a tidyllm TOOL
claude_list_models

List Available Models from the Anthropic Claude API
claude_list_files

List Files in Claude API
codex_cli_chat

Chat with OpenAI models through your own installed Codex CLI
check_batch

Check Batch Processing Status
codex_cli

Chat through a locally installed Codex CLI
fetch_groq_batch

Fetch Results for a Groq Batch
fetch_gemini_batch

Fetch Results for a Gemini Batch
fetch_claude_batch

Fetch Results for a Claude Batch
fetch_batch

Fetch Results from a Batch API
gemini_list_files

List Files in Gemini API
gemini_chat

Send LLMMessage to Gemini API
field_box

Ask decide() to find something in an image (experimental)
fetch_openai_batch

Fetch Results for an OpenAI Batch
gemini_list_models

List Available Models from the Google Gemini API
gemini

Google Gemini Provider Function
file_info

Get Metadata for a File Stored on a Provider
claude_file_metadata

Retrieve Metadata for a File from Claude API
gemini_delete_file

Delete a File from Gemini API
deepseek

Deepseek Provider Function
get_reply

Retrieve Assistant Reply as Text
get_reply_data

Retrieve Assistant Reply as Structured Data
gemini_upload_file

Upload a File to Gemini API
get_logprobs

Retrieve Log Probabilities from Assistant Replies
list_groq_batches

List Groq Batch Requests
list_gemini_batches

List Recent Gemini Batch Operations
fetch_mistral_batch

Fetch Results for an Mistral Batch
fetch_job

Fetch the Results of a Job
deep_research

Run Deep Research via a Provider
decide

Answer questions about a text, an image or a recording with a decision model
field_chr

Define Field Descriptors for JSON Schema
field_object

Define a nested object field
img

Create an Image Object
get_metadata

Retrieve Metadata from Assistant Replies
get_partial

The text a running chat has produced so far
claude_websearch

Builtin Claude Web Search Tool
jev

Jev and System One compatible servers
llamacpp_delete_model

Delete a Local GGUF Model File
gemini_file_metadata

Retrieve Metadata for a File from Gemini API
fetch_azure_openai_batch

Fetch Results for an Azure OpenAI Batch
gemini_embedding

Generate Embeddings Using the Google Gemini API
embed

Generate text embeddings
deepseek_chat

Send LLM Messages to the DeepSeek Chat API
groq

Groq API Provider Function
groq_chat

Send LLM Messages to the Groq Chat API
list_files

List Files Stored on a Provider
list_claude_batches

List Claude Batch Requests
get_user_message

Retrieve a User Message by Index
get_stream

A running chat's deltas, as a stream
list_hf_gguf_files

List GGUF Files Available in a Hugging Face Repository
list_mistral_batches

List Mistral Batch Requests
mistral_embedding

Generate Embeddings Using Mistral API
groq_list_models

List Available Models from the Groq API
groq_transcribe

Transcribe an Audio File Using Groq transcription API
llamacpp

llama.cpp Provider Function
llamacpp_health

Check Health of the llama.cpp Server
llamacpp_embedding

Generate Embeddings Using a llama.cpp Server
llamacpp_list_models

List Models Loaded in the llama.cpp Server
ollama_embedding

Generate Embeddings Using Ollama API
llamacpp_list_local_models

List Local GGUF Model Files
openai_deep_research

Submit a Deep Research Request to OpenAI
mistral_list_models

List Available Models from the Mistral API
list_batches

List all Batch Requests on a Batch API
list_azure_openai_batches

List Azure OpenAI Batch Requests
list_models

List Available Models for a Provider
ollama

Ollama API Provider Function
list_openai_batches

List OpenAI Batch Requests
ollama_delete_model

Delete a model from the Ollama API
ollama_chat

Interact with local AI models via the Ollama API
openai_embedding

Generate Embeddings Using OpenAI API
ollama_download_model

Download a model from the Ollama API
llamacpp_chat

Send LLM Messages to a llama.cpp Server
llamacpp_download_model

Download a GGUF Model from Hugging Face
openai_list_models

List Available Models from the OpenAI API
openai_fetch_research

Fetch Results from a Completed OpenAI Deep Research Job
send_chat

Start a chat without waiting for it
send_batch

Send a batch of messages to a batch API
parallel_chat

Send many chats at once
openrouter_list_models

List Available Models on OpenRouter
openrouter

OpenRouter Provider Function
openai_websearch

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

Rerank Documents Using a llama.cpp Server
perplexity

Removed: perplexity()
llm_message

Create or Update Large Language Model Message Object
openrouter_embedding

Generate Embeddings Using the OpenRouter API
ollama_list_models

Retrieve and return model information from the Ollama API
send_claude_batch

Send a Batch of Messages to Claude API
openrouter_generation

Get Details for an OpenRouter Generation
pdf_file

Create a PDF Object
send_gemini_batch

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

Send LLM Messages to the OpenAI Responses API
mistral_chat

Send LLMMessage to Mistral API
mistral

Mistral Provider Function
openai

The openai() function acts as an interface for interacting with the OpenAI API through main tidyllm verbs such as chat(), embed(), and send_batch(). Chat uses the Responses API (POST /v1/responses); embeddings and batch operations use the Chat Completions / Embeddings endpoints unchanged.
pdf_page_batch

Batch Process PDF into LLM Messages
send_ollama_batch

Send a Batch of Messages to Ollama API
tidyllm_schema

Create a JSON Schema for Structured Outputs
send_groq_batch

Send a Batch of Messages to the Groq API
provider_capabilities

What each provider supports
upload_file

Upload a File to a Provider's File Store
tidyllm-package

tidyllm: Tidy Integration of Large Language Models
rate_limit_info

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

Send a Batch of Messages to Azure OpenAI Batch API
openai_check_research

Check the Status of an OpenAI Background Research Job
openai_code_interpreter

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

Send LLM Messages to the OpenRouter Chat API
tidyllm_tool

Create a Tool Definition for tidyllm
send_mistral_batch

Send a Batch of Requests to the Mistral API
tidyllm_example_app

Run a tidyllm example Shiny app
openrouter_credits

Get OpenRouter Credit Balance
websearch

Search the Web
voyage_rerank

Rerank Documents Using Voyage AI API
voyage

Voyage Provider Function
send_openai_batch

Send a Batch of Messages to OpenAI Batch API
voyage_embedding

Generate Embeddings Using Voyage AI API
websearch_tool

Give a Model Web Search
video_file

Create a Video Object
vibe_cli_chat

Chat with Mistral models through your own installed Mistral Vibe CLI
vibe_cli

Chat through a locally installed Mistral Vibe CLI
cancel_job

Stop a running chat
azure_openai_chat

Send LLM Messages to an Azure OpenAI Chat Completions endpoint
azure_openai

Azure OpenAI Endpoint Provider Function
audio_file

Create an Audio Object
box_to_pixels

Turn the fractions of box answers into pixel positions
cancel_openai_batch

Cancel an In-Progress OpenAI Batch
azure_openai_embedding

Generate Embeddings Using OpenAI API on Azure
LLMMessage

Large Language Model Message Class
chat_completions_chat

Chat with any OpenAI-Compatible API Endpoint
chat

Chat with a Language Model
check_azure_openai_batch

Check Batch Processing Status for Azure OpenAI Batch API
check_gemini_batch

Check the Status of a Gemini Batch Operation
chat_ellmer

Send LLM Messages to Ellmer Chat Object
check_openai_batch

Check Batch Processing Status for OpenAI Batch API
check_claude_batch

Check Batch Processing Status for Claude API
check_groq_batch

Check Batch Processing Status for Groq API
check_mistral_batch

Check Batch Processing Status for Mistral Batch API
chatgpt

Alias for the OpenAI Provider Function