Package: LLMR 0.8.9

LLMR: Interface for Large Language Model APIs in R

Provides a unified interface to large language models across multiple providers. Supports text generation, tidy data workflows, structured output with optional JSON Schema validation, XML-like tag extraction, and embeddings. Includes chat sessions, consistent error handling, and parallel batch tools.

Authors:Ali Sanaei [aut, cre]

LLMR_0.8.9.tar.gz
LLMR_0.8.9.zip(r-4.7)LLMR_0.8.9.zip(r-4.6)LLMR_0.8.9.zip(r-4.5)
LLMR_0.8.9.tgz(r-4.6-any)LLMR_0.8.9.tgz(r-4.5-any)
LLMR_0.8.9.tar.gz(r-4.7-any)LLMR_0.8.9.tar.gz(r-4.6-any)
LLMR_0.8.9.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
LLMR/json (API)

# Install 'LLMR' in R:
install.packages('LLMR', repos = c('https://asanaei.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/asanaei/llmr/issues

Pkgdown/docs site:https://asanaei.github.io

Datasets:

On CRAN:

Conda:

7.67 score 8 stars 72 scripts 621 downloads 79 exports 39 dependencies

Last updated from:f10f870efd. Checks:7 NOTE, 2 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64NOTE180
source / vignettesOK224
linux-release-x86_64NOTE162
macos-release-arm64NOTE109
macos-oldrel-arm64NOTE130
windows-develNOTE135
windows-releaseNOTE108
windows-oldrelNOTE115
wasm-releaseOK159

Exports:bind_toolsbuild_factorial_experimentscache_llm_callcall_llmcall_llm_broadcastcall_llm_comparecall_llm_parcall_llm_par_structuredcall_llm_par_tagscall_llm_robustcall_llm_streamcall_llm_sweepcall_llm_toolschat_sessiondiagnosticsdisable_structured_outputenable_structured_outputensure_alternating_messagesexpand_llm_configfinish_reasonget_batched_embeddingsis_truncatedllm_add_request_hashllm_agreementllm_api_key_envllm_batch_cancelllm_batch_fetchllm_batch_statusllm_batch_submitllm_configllm_cross_designllm_failuresllm_fnllm_fn_structuredllm_fn_tagsllm_hashllm_judgellm_log_activellm_log_disablellm_log_enablellm_log_mergellm_log_readllm_log_statusllm_logprobsllm_methods_textllm_mutatellm_mutate_structuredllm_mutate_tagsllm_par_resumellm_parse_rowpack_tagsllm_parse_structuredllm_parse_structured_colllm_parse_tagsllm_parse_tags_colllm_persona_demographic_fieldsllm_persona_dictionaryllm_persona_overviewllm_persona_splitllm_previewllm_render_messagesllm_replicatellm_request_from_logllm_request_hashllm_response_recordllm_toolllm_tool_signaturellm_usagellm_uuidllm_validate_persona_framellm_validate_structured_collog_llm_errorparse_embeddingsreportresetreset_llm_parallelsetup_llm_paralleltokenstool_callstranscript_as_messages

Dependencies:askpassbase64enccachemclicodetoolscpp11curldigestdplyrfastmapfuturefuture.applygenericsglobalsgluehttr2jsonlitelifecyclelistenvmagrittrmemoisemimeopensslparallellypillarpkgconfigpurrrR6rappdirsrlangstringistringrsystibbletidyrtidyselectutf8vctrswithr

A Trolley Dilemma Experiment with LLMR
Designing the Experiment | Vectorised Execution with Soft Structuring | Conclusion

Last update: 2026-06-25
Started: 2026-06-05

Schema-validated output in LLMR
Overview | What the major providers actually support | Why prefer schema output? | Why JSON-only still matters | Quirks you will hit in practice | LLMR helpers for common parsing failures | Minimal patterns (guarded code) | 1) JSON mode, no schema (works across OpenAI-compatible providers) | 2) Schema mode that actually works (Groq, open model) | 3) DeepSeek: JSON-object mode with local validation | 4) Groq: another structured output example | Defensive patterns (no API calls) | Parallel execution with schema validation | Choosing the mode | References

Last update: 2026-06-25
Started: 2025-08-27

Presidential Speech Analysis with Embeddings
Prepare the Text Data | Configure Embedding Model | Generate Embeddings | Analyze Similarity | Expected Results

Last update: 2026-06-25
Started: 2025-05-27

Reproducibility and cost: logging, replication, caching, batch jobs
1. An audit trail for every call | 2. Replication and reliability | 3. A methods paragraph you can edit | 4. What did it cost? | 5. Prompt caching | 6. Batch jobs at half price | 7. Seeds, versions, and honest limits

Last update: 2026-06-25
Started: 2026-06-10

LLMR in 5 minutes
1. Install | 2. Set an API key | 3. Your first call | 4. Apply a model to a data frame | 5. Generative calls over a vector | 6. Tagged fields and row batching | 7. Embeddings | 8. Look before you spend, summarize after | Where to go next

Last update: 2026-06-17
Started: 2026-06-09

Tidy pipelines and structured output
llm_fn: unstructured (DeepSeek) | llm_fn: unstructured (Groq) | llm_fn_structured: schema-first (DeepSeek) | llm_mutate: unstructured (Groq) | llm_mutate: shorthand syntax | llm_mutate with .structured flag | Soft structured output with tags | Row batching: many rows per call | Preview before you spend, summarize after | llm_mutate_structured: structured with shorthand (Groq)

Last update: 2026-06-17
Started: 2025-08-27

Small experiment with LLMR
Overview | Build a factorial design | Run unstructured | Structured version

Last update: 2026-06-16
Started: 2025-08-27

Interactive calls: tools, streaming, and logprobs
Tools: the model consults your R session | Streaming: watch the reply arrive | Logprobs: the model's confidence as data | Where the other machinery lives

Last update: 2026-06-10
Started: 2026-06-10

Simple chat with LLMR
DeepSeek: deepseek-chat | DeepSeek: deepseek-reasoner | Groq: llama-3.1-8b-instant | Groq: openai/gpt-oss-20b | Using the chat history | Inspect the full conversation | Structured chat in one call (DeepSeek example)

Last update: 2026-06-05
Started: 2025-08-27

Readme and manuals

Help Manual

Help pageTopics
Example participant profiles derived from ANES 2024anes_2024_personas
Bind tools to a config (provider-agnostic)bind_tools
Build Factorial Experiment Designbuild_factorial_experiments
Call an LLM (chat/completions or embeddings) with optional multimodal inputcall_llm call_llm.ollama
Parallel API calls: Fixed Config, Multiple Messagescall_llm_broadcast
Parallel API calls: Multiple Configs, Fixed Messagecall_llm_compare
Parallel LLM Processing with Tibble-Based Experiments (Core Engine)call_llm_par
Parallel experiments with structured parsingcall_llm_par_structured
Parallel experiments with tag parsingcall_llm_par_tags
Robustly Call LLM API (Simple Retry)call_llm_robust
Stream a chat completion token by tokencall_llm_stream
Parallel API calls: Parameter Sweep - Vary One Parameter, Fixed Messagecall_llm_sweep
Call an LLM with tools and run the tool loopcall_llm_tools
Machine-readable diagnostics for an LLMR-family result objectdiagnostics
Disable Structured Output (clean provider toggles)disable_structured_output
Enable Structured Output (Provider-Agnostic)enable_structured_output
Make a message array provider-safe (alternating, user-leading)ensure_alternating_messages
Expand an LLM Config Gridexpand_llm_config
Generate Embeddings in Batchesget_batched_embeddings
Append the audit-log request hash to a parallel-results framellm_add_request_hash
Agreement across replicated LLM annotationsllm_agreement
Declare an API key sourced from an environment variablellm_api_key_env
Cancel a batch jobllm_batch_cancel
Fetch the results of a batch jobllm_batch_fetch
Check the status of a batch jobllm_batch_status
Submit a batch job to a provider's batch APIllm_batch_submit
Chat Session Object and Methodsas.data.frame.llm_chat_session chat_session head.llm_chat_session llm_chat_session print.llm_chat_session summary.llm_chat_session tail.llm_chat_session
Create an LLM configuration (provider-agnostic)llm_config
Cross a data frame with LLM configsllm_cross_design
List the rows of an LLM run that failed or were truncatedllm_failures
Apply an LLM prompt over vectors/data framesllm_fn
Vectorized structured-output LLMllm_fn_structured
Vectorized LLM with tag extractionllm_fn_tags
Content hash for research artifactsllm_hash
LLM-as-a-Judge Evaluationllm_judge
Record every LLM call in a local audit logllm_log_active llm_log_disable llm_log_enable llm_log_merge llm_log_status
Read an LLMR audit log into records and a manifestllm_log_read
Extract token log-probabilities from a responsellm_logprobs
Draft a methods-section paragraph from an LLM runllm_methods_text
Mutate a data frame with LLM outputllm_mutate
Data-frame mutate with structured outputllm_mutate_structured
Data-frame mutate with XML-like tag outputllm_mutate_tags
Resume failed parallel LLM callsllm_par_resume
Parse a batched, row-wrapped tag response into per-row field listsllm_parse_rowpack_tags
Parse structured output emitted by an LLMllm_parse_structured
Parse structured fields from a column into typed vectorsllm_parse_structured_col
Parse XML-like tags emitted by an LLMllm_parse_tags
Parse XML-like tag fields from a columnllm_parse_tags_col
Which columns of a persona frame are demographicsllm_persona_demographic_fields
The question dictionary attached to a persona data framellm_persona_dictionary
A compact overview of a persona frame for displayllm_persona_overview
Split one persona into labeled demographics and labeled answersllm_persona_split
Preview a tidy LLM call without spending anythingllm_preview
Render tidy messages without calling any APIllm_render_messages
Run the same prompt several times per rowllm_replicate
Rebuild a callable request from a logged recordllm_request_from_log
Stable request hash for an LLM callllm_request_hash
Flatten one LLM response to a provenance rowllm_response_record
Define a tool the model may callllm_tool
A stable signature for a tool's identityllm_tool_signature
Summarize token usage and outcomes of an LLM runllm_usage
A short, sortable, process-unique identifierllm_uuid
Check that a data frame follows the persona contractllm_validate_persona_frame
Validate structured JSON objects against a JSON Schema (locally)llm_validate_structured_col
LLMR Response Objectas.character.llmr_response finish_reason is_truncated llmr_response print.llmr_response tokens
Parse Embedding Response into a Numeric Matrixparse_embeddings
Print an LLM configuration with the API key maskedformat.llm_config print.llm_config
Draft a methods-section report from an LLMR-family result objectreport
Reset a stateful object to its initial positionreset
Reset Parallel Environmentreset_llm_parallel
Setup Parallel Environment for LLM Processingsetup_llm_parallel
Extract tool calls from a responsetool_calls
Build a role-flipped message array from a multi-speaker transcripttranscript_as_messages