Chat with Large Language Models
Overview
Chat with large language models from a range of providers including 'Claude' https://claude.ai, 'OpenAI' https://chatgpt.com, and more. Supports streaming, asynchronous calls, tool calling, and structured data extraction.
Lifecycle changes
chat_github()andmodels_github()are now defunct because GitHub Models has been retired (@thisisnic, #1069).tool()functions that return complex objects like data frames or lists now produce a deprecation warning. Tool functions should return a character vector, an atomic vector, a JSON string (fromjsonlite::toJSON()), or aContentobject. Usejsonlite::toJSON()to convert complex objects before returning (@thisisnic, #858).
New features
- When running on Posit Connect, ellmer now forwards the viewer's session token to Connect's LLM gateway so gateway usage can be attributed to the viewer. This happens automatically for Shiny content and only affects requests to the gateway (@karawoo, #1105).
chat_aws_bedrock()gains anapiargument to select between the Converse API on thebedrock-runtimeendpoint and the Anthropic Messages or OpenAI Responses APIs on thebedrock-mantleendpoint. This makes models that Converse can't serve, like Claude Mythos and the GPT-5 family, available on Bedrock. The API is picked frommodelby default, so you only need to setapifor models ellmer doesn't recognize (#1064).Chatgains experimental$file_upload(),$file_list(),$file_get(),$file_download(), and$file_delete()methods for managing provider-hosted files withchat_openai(),chat_anthropic(), andchat_google_gemini(): upload a file once, then pass the returned reference to$chat()instead of re-sending the file's contents every turn. Uploads expire after 48 hours by default; useexpires_in_hto change this.claude_file_upload()and friends andgoogle_upload()are deprecated in favor of these (@thisisnic, #1091).Chatgains$get_rounds()and$last_round()methods for retrieving the conversation history grouped intoRounds. The newRoundclass groups aChat's flat turn history into rounds, each containing a user turn and the assistant/tool-result turns that follow it (#507).Chatgains$on_request_start()and$on_request_end()callbacks that fire before and after each model request, including each round of the tool loop.$on_request_start()receives the turns about to be sent, so you can inspect the request or compact the conversation with$set_turns().$on_request_end()receives the assistant turn just returned, so you can track latency or cost per request (@kaipingyang, #1051).Chat$stream()andChat$stream_async()gain atypeargument for streaming structured output from providers with native support (@cpsievert, #1102).Chatgains a$token_count()method that estimates the number of tokens in new input using the provider's token counting endpoint (@thisisnic, #814).claude_tool_web_search(),claude_tool_web_fetch(citations = TRUE),google_tool_web_search(), andopenai_tool_web_search()now return citations, which are preserved in chat history and streamed content and shown as cited sources in console output (@cpsievert, #775).
Show all changes in 0.5.0Hide the rest of the changes in 0.5.0
- New
content_document_file()andcontent_document_url()send text-based documents like CSV, markdown, and code files to the model, andcontent_pdf_url()now lets providers that can fetch URLs do so themselves (@thisisnic, #1090). - New
Modelclass separates model configuration (name, parameters, extra arguments) from theProviderclass, which now only captures API endpoint details.Chatgains a new$get_model_object()method to retrieve theModelobject.provider@model,provider@params, andprovider@extra_argsare deprecated and will be removed in a future release; use theModelobject instead (@thisisnic, #1098). - New
models_update_prices()downloads the latest model pricing data from GitHub and saves it to a local cache. Subsequent calls totoken_usage()and related functions will use the updated prices (#968). tool_context()lets a tool access its calling context, including theContentToolRequestand the conversation history, during a tool call.with_tool_context()andlocal_tool_context()support testing tools that use it (#871).
Minor improvements and bug fixes
- Default models have been updated for a number of providers (@thisisnic, #1040, #1066, #1125):
chat_anthropic()now usesclaude-sonnet-5.chat_aws_bedrock()now usesus.anthropic.claude-sonnet-5.chat_databricks()now usesdatabricks-claude-sonnet-5.chat_google_gemini()andchat_google_vertex()now usegemini-3.7-flash.chat_huggingface()now usesQwen/Qwen3-235B-A22B-Instruct-2507.chat_openai()now usesgpt-5.6-terra.chat_openrouter()now usesgpt-5.6-terra.chat_posit()now usesclaude-sonnet-5.chat_snowflake()now usesclaude-sonnet-5.chat_anthropic()andchat_aws_bedrock()now handle empty responses from the model (@thisisnic, #1070).chat_anthropic()now defaultsbase_urlto theANTHROPIC_BASE_URLenvironment variable, andchat_aws_bedrock()toAWS_ENDPOINT_URL_BEDROCK_RUNTIMEorAWS_ENDPOINT_URL_BEDROCK_MANTLEdepending onapi, matching the official SDKs (@karawoo, #1103).chat_anthropic()now handles thefallbackcontent block returned when a model's server-side refusal fallback (server-side-fallback-2026-06-01) is triggered (@simonpcouch, #1057).chat_aws_bedrock()now handles thinking blocks with no text (@thisisnic, #1085).chat_aws_bedrock()now supports bearer token authentication for enterprise API gateways (@thisisnic, #1002).chat_databricks()now supports models that return content as an array of typed objects (e.g.databricks-gpt-oss-120b), capturing reasoning parts as thinking content (@thisisnic, #1078).chat_databricks()now works with tools that have no arguments (@thisisnic, #1084).Chatgains aconversation_idactive binding. When set, it is recorded on the OpenTelemetry spans emitted for each model call so that tracing backends can group spans belonging to the same conversation (@cpsievert, #1106).chat_google_gemini()now supports mixing regular tools with built-in tools likegoogle_tool_web_search()(@thisisnic, #1054).chat_openrouter()now preserves provider error messages (@xmarquez, #1059).params(top_k = )is now sent astop_krather thantop_logprobsfor OpenAI-based providers (@thisisnic, #1113).
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-07-19
- ERROR10 OK, 3 ERROR2026-07-07
- OK13 OK2026-06-11
Show 6 earlier changesHide 6 earlier changes
- ERROR12 OK, 1 ERROR2026-06-09
- OK13 OK2026-06-08
- ERROR12 OK, 1 ERROR2026-06-07
- OK13 OK2026-06-01
- ERROR12 OK, 1 ERROR2026-05-29
- OK14 OK2026-03-10
Documentation
- Help pages
- 61 (3 internal)includes a package overview page
- Examples that run
- 44%22 run in a plain check (3 of them under a condition) · 28 never run
- Exported functions with examples
- 83%
- Documented parameters
- 93%
- Return-value docs
- 78%
- Help pages citing references
- 0%
Downloads
Repository
- PRs merged (all time)
- 90%
- Median days to close, 50 most recently updated closed issues
- 24
- Median days to close, 50 most recently updated closed PRs
- 13
Stars over time
Forks over time
Releases over time
Issues over time
PRs over time
Commits over time
Commit identities over time
15 development-tooling and community-health practices detected across 7 families in the upstream repository
Checks run against github.com/tidyverse/ellmer 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-10-18 · The repository has a site deploy workflow
pkgdown site last built 2026-10-15
Show all practicesHide 3 practices
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2025-07-19Seen in the repository: .claude, .claude/skillsNamed in .Rbuildignore: .claudePull request it wrote: opened by a project memberCommits: at least 5 crediting it in the message
- Claude CodePull requests: 6 from outside contributors, first on 2026-02-14, 6 from forks
- Claude Opus 4.62 commits · May to Jun 2026
- Claude Fable 5.11 commit · Oct 2026
- Claude Opus 4.71 commit · Jun 2026
Dependencies
Installing ellmer adds 25 packages (16 with compiled code, 13 MB of source tarballs). Heaviest: promises 3.1 MB, Rcpp 1.8 MB, openssl 1.1 MB.
Show the 48 most downloaded packagesHide the 48 most downloaded packages
Code & Tests
People & History
Pick two releases to compare their code metrics.
- 0.5.0Latest2026-09-04 · current release · diff ↗ ·
added 19 exports
Chat, ContentCitation, ContentDocument, ContentToolRequestFetch, ContentToolRequestSearch, ContentToolResponseFetch, ContentToolResponseSearch, ContentUploaded, Model, Round, Source, ToolDef, WebSource, content_document_file, content_document_url, local_tool_context, models_update_prices, tool_context, with_tool_context - 0.4.2
- 0.4.12026-05-07 · diff ↗ ·
added 4 exports
AssistantPartialTurn, chat_lmstudio, models_lmstudio, stream_controller - RR 4.6.0 released · 2026-04-24
- 0.4.02025-11-15 · diff ↗ ·
removed 4 exports
chat_azure, chat_bedrock, chat_cortex, chat_geminiadded 19 exports
AssistantTurn, SystemTurn, TypeIgnore, UserTurn, chat_openai_compatible, claude_file_delete, claude_file_download, claude_file_get, claude_file_list, claude_file_upload, claude_tool_web_fetch, claude_tool_web_search, df_schema, google_tool_web_fetch, google_tool_web_search, models_claude, models_mistral, openai_tool_web_search, type_ignore - 0.3.22025-09-04 · diff ↗
- 0.3.12025-08-24 · diff ↗
- 0.3.02025-07-25 · diff ↗ ·
removed 1 export
chat_cortex_analystadded 6 exports
batch_chat_text, chat, contents_record, contents_replay, models_github, parallel_chat_text - 0.2.1
- 0.2.02025-05-18 · diff ↗ ·
added 28 exports
ContentThinking, batch_chat, batch_chat_completed, batch_chat_structured, chat_anthropic, chat_aws_bedrock, chat_azure_openai, chat_cloudflare, chat_google_gemini, chat_google_vertex, chat_huggingface, chat_mistral, chat_portkey, google_upload, interpolate_package, models_anthropic, models_aws_bedrock, models_google_gemini, models_google_vertex, models_ollama, models_openai, models_portkey, models_vllm, parallel_chat, parallel_chat_structured, params, tool_annotations, tool_reject - RR 4.5.0 released · 2025-04-11
- 0.1.12025-02-07 · diff ↗ ·
added 7 exports
ContentPDF, chat_cortex_analyst, chat_deepseek, chat_openrouter, chat_snowflake, content_pdf_file, content_pdf_url - 0.1.02025-01-09
- RR 4.4.0 released · 2024-04-24
Package metadata
- First published
- 2025-01-09
- Total releases
- 11 / 1 yrs
- License
- MIT + file LICENSE OSI
- Minimum R
- ≥ 4.1
- Download size
- 3.0 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("ellmer")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-22, which the citation names so these numbers can be found later. More on citing and the projects behind them.