Interface for Large Language Model APIs in R
Overview
One interface to many large language model providers: a single configuration object and a single calling function serve chat and embedding models alike, so research code does not change when the provider does. The same calls scale to multi-model and multi-condition studies. Small open models can also run on the user's computer through 'llama.cpp', downloaded only on request, with access to next-token probabilities.
Local models
- LLMR can run small open models on the user's computer through llama.cpp.
llm_local_install()downloads, on request, the llama.cpp server program for the platform and a model's GGUF file from Hugging Face; it lists each file with its size, source, and license and asks for agreement first, pins every file to an exact version, checks its sha256, and makes no network request when the files are present.llm_local_models()lists the models available by name (Qwen3 0.6B, Qwen3.5 0.8B in 8 and 4 bits and its base model, IBM Granite 4.0 350M and its base model, SmolLM2 135M and 360M, and the multilingual embedding models multilingual-e5-small, Granite Embedding 311M, EmbeddingGemma 2, and bge-m3);llm_local_model()adds any GGUF file on Hugging Face.llm_local_status(),llm_local_start(),llm_local_stop(),llm_local_ready(),llm_local_dir(), andllm_local_uninstall()manage the files and servers.
Show all changes in 0.9.0Hide the rest of the changes in 0.9.0
- New provider
"llamacpp":llm_config("llamacpp", model)runs an installed model, starting its server on first use and stopping it when R exits. Chat, streaming, structured output, tools, log-probabilities, and embeddings work as for hosted providers.thinking = FALSEturns off the reasoning step of models such as Qwen3. For embedding models,task =adds the model's task prefix anddimensions =truncates to a trained size. Withapi_url, a llama.cpp server the user runs is used instead. - Token-level functions for local models:
llm_next_token()returns the next-token distribution (the top tokens, or the whole vocabulary) after a chat or a raw prompt;llm_continue()continues a reply whose beginning the user writes, any number of times, sampling from the model's full distribution unless told otherwise;llm_score()gives the log-probability of each token of a text the model did not write;llm_choice_probs()compares the probabilities of several options;llm_tokenize(),llm_detokenize(), andllm_render_template()expose the tokenizer and the exact text the model reads. Each result records the model, the sha256 of its file, the llama.cpp build, the device, and the context. - LLMR now imports processx, which supervises the local servers, and requires curl 5.0.0 or later, whose
multi_download()resumes interrupted downloads.
Other changes
parse_embeddings()returns rows in the order of the response'sindexfields when the provider reports them.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK14 OK2026-03-10
Documentation
- Help pages
- 79 (1 internal)includes a package overview page
- Examples that run
- 62%38 run in a plain check (1 of them under a condition) · 23 never run
- Exported functions with examples
- 79%
- Documented parameters
- 96%
- Return-value docs
- 100%
- Help pages citing references
- 1%
- A Trolley Dilemma Experiment with LLMR HTML
- Interactive calls: tools, streaming, and logprobs HTML
- JSON output vs. schema-validated output in LLMR HTML
- LLMR in 5 minutes HTML
- Local models: token probabilities, prefilled replies, and embeddings HTML
- Presidential Speech Analysis with Embeddings HTML
- Reproducibility and cost: logging, replication, caching, batch jobs HTML
- Simple chat with LLMR HTML
- Small experiment with LLMR HTML
- Tidy pipelines and structured output HTML
Downloads
Repository
- PRs merged (all time)
- not measured
- Median days to close, 50 most recently updated closed issues
- 121
- Median days to close, 50 most recently updated closed PRs
- not measured
Stars over time
Issues over time
Commits over time
9 development-tooling and community-health practices detected across 6 families in the upstream repository
Checks run against github.com/asanaei/llmr on 2026-10-18.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-08-05 · The repository has a site deploy workflow
pkgdown site last built 2026-05-01, before release 0.9.0 (2026-10-20)
Show all practicesHide 2 practices
Dependencies
Installing LLMR adds 39 packages (25 with compiled code, 23 MB of source tarballs). Heaviest: stringi 11 MB, openssl 1.1 MB, jsonlite 1.0 MB.
Code & Tests
Datasets
People & History
Pick two releases to compare their code metrics.
- 0.9.0Latest2026-10-20 · current release · diff ↗ ·
removed 1 export
llm_methods_text·added 16 exports
llm_choice_probs, llm_continue, llm_detokenize, llm_local_dir, llm_local_install, llm_local_model, llm_local_models, llm_local_ready, llm_local_start, llm_local_status, llm_local_stop, llm_local_uninstall, llm_next_token, llm_render_template, llm_score, llm_tokenizelisted once in CRAN's queue
Seen in one reading of CRAN's incoming queue, at 2026-10-20 01:24 UTC, so it stayed less than the time between readings. - 0.8.112026-07-24 · diff ↗ ·
removed 10 exports
bind_tools, cache_llm_call, expand_llm_config, llm_add_request_hash, llm_cross_design, llm_log_merge, llm_parse_rowpack_tags, llm_persona_dictionary, llm_uuid, log_llm_error - 0.8.102026-07-10 · diff ↗ ·
added 12 exports
ensure_alternating_messages, llm_add_request_hash, llm_log_active, llm_log_merge, llm_persona_demographic_fields, llm_persona_dictionary, llm_persona_overview, llm_persona_split, llm_tool_signature, llm_uuid, llm_validate_persona_frame, transcript_as_messages - 0.8.62026-06-17 · diff ↗ ·
added 35 exports
call_llm_par_tags, call_llm_stream, call_llm_tools, diagnostics, expand_llm_config, llm_agreement, llm_api_key_env, llm_batch_cancel, llm_batch_fetch, llm_batch_status, llm_batch_submit, llm_cross_design, llm_failures, llm_fn_tags, llm_hash, llm_judge, llm_log_disable, llm_log_enable, llm_log_read, llm_log_status, llm_logprobs, llm_methods_text, llm_par_resume, llm_parse_rowpack_tags, llm_preview, llm_render_messages, llm_replicate, llm_request_from_log, llm_request_hash, llm_response_record and 5 more - 0.6.4
- RR 4.6.0 released · 2026-04-24
- 0.6.3
- 0.6.02025-08-26 · diff ↗ ·
added 13 exports
bind_tools, call_llm_par_structured, disable_structured_output, enable_structured_output, finish_reason, is_truncated, llm_api_key_env, llm_fn_structured, llm_mutate_structured, llm_parse_structured, llm_parse_structured_col, llm_validate_structured_col, tokens - 0.5.02025-07-17 · diff ↗ ·
removed 3 exports
Agent, AgentAction, LLMConversationadded 1 export
chat_session - 0.4.2
- 0.3.02025-05-28 · diff ↗ ·
added 7 exports
call_llm_broadcast, call_llm_compare, call_llm_par, call_llm_sweep, get_batched_embeddings, reset_llm_parallel, setup_llm_parallel - RR 4.5.0 released · 2025-04-11
- 0.2.5
- 0.2.32025-03-13 · diff ↗
- 0.2.1
- 0.1.2
Show 2 earlier eventsHide 2 earlier events
- 0.1.12024-10-21
- RR 4.4.0 released · 2024-04-24
Package metadata
- First published
- 2024-10-21
- Total releases
- 15 / 2 yrs
- License
- MIT + file LICENSE OSI
- Minimum R
- ≥ 4.1.0
- Bundled data
- 17 KB / 1 file
- Download size
- 741 KB
Cite
Cite this package
Run in R for the authors' entry:
citation("LLMR")The package provides a citation file, so citation() returns the authors' own entry.
The repository also keeps a CITATION.cff.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-21, which the citation names so these numbers can be found later. More on citing and the projects behind them.