The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

foundryR vs ellmer

library(foundryR)

foundryR and ellmer both make language-model work possible from R. They are not substitutes for every use case. ellmer is the better fit for provider-portable chat. foundryR is the better fit when the work is tied to Azure AI Foundry and the output needs to become data. The two are complementary: you can describe a structure once with ellmer’s type system and hand it to foundryR for strict, tibble-shaped extraction.

Comparison

Question Use foundryR Use ellmer
Are you committed to Azure AI Foundry? Yes Sometimes
Do you need Azure AI Content Safety? Yes No
Do you need Azure’s Files and Batch APIs? Yes No
Do you need strict schema-constrained extraction as tibbles? Yes Sometimes
Do you need embeddings inside a dataframe workflow? Yes Sometimes
Do you need step_foundry_embed() in a tidymodels recipe? Yes No
Do you need multi-provider chat? No Yes
Do you need interactive streaming chat? No Yes
Do you need a chat-first tool-calling agent interface? Basic Responses API loop Yes

Where foundryR fits

Use foundryR when your work starts or ends in a dataframe. Common examples are:

Azure’s own Batch API matters here. ellmer supports batch workflows for native OpenAI and Anthropic endpoints, but it does not target Azure’s Files and Batch API surface.

Where ellmer fits

Use ellmer when chat is the product interface. It gives you a provider-neutral chat abstraction, interactive streaming, and a mature chat-first tool-calling workflow. That is the right shape for assistants, notebooks where you want token streaming, or applications that may move between providers.

foundryR deliberately does not implement streaming. For streaming chat in R, use ellmer.

Interop: reuse an ellmer type as a foundryR schema

If you already describe your data with ellmer’s type system, you do not have to rewrite it. as_foundry_schema() converts an ellmer::type_object() into the strict JSON Schema that foundry_extract() expects. This conversion is a local operation – no network, no credentials – so its output is shown here directly.

library(ellmer)
#> 
#> Attaching package: 'ellmer'
#> The following objects are masked from 'package:foundryR':
#> 
#>     type_boolean, type_enum, type_number, type_string

# Describe the structure you want with ellmer's type system.
sentiment_spec <- type_object(
  sentiment = type_enum(
    c("positive", "negative", "neutral"),
    description = "Overall sentiment of the response."
  ),
  theme = type_string("A short theme label for the response.")
)

# Convert it into a foundryR schema for strict extraction.
sentiment_schema <- as_foundry_schema(sentiment_spec)
str(sentiment_schema)
#> List of 4
#>  $ type                : chr "object"
#>  $ properties          :List of 2
#>   ..$ sentiment:List of 3
#>   .. ..$ type       : chr "string"
#>   .. ..$ enum       : 'AsIs' chr [1:3] "positive" "negative" "neutral"
#>   .. ..$ description: chr "Overall sentiment of the response."
#>   ..$ theme    :List of 2
#>   .. ..$ type       : chr "string"
#>   .. ..$ description: chr "A short theme label for the response."
#>  $ required            : 'AsIs' chr [1:2] "sentiment" "theme"
#>  $ additionalProperties: logi FALSE

Extraction with foundryR

Hand the converted schema to foundry_extract(). foundryR sends each input through the Responses API with strict decoding and returns one tidy row per input – the model’s output has already become data.

foundry_extract(
  c("The lesson was clear.", "I wanted more examples."),
  schema = sentiment_schema
)
#> # A tibble: 2 × 10
#>   .input_idx .input_text     .response_id .status .output_text .error .error_msg
#>        <int> <chr>           <chr>        <chr>   <chr>        <lgl>  <chr>     
#> 1          1 The lesson was… resp_06e39d… comple… "{\"sentime… FALSE  <NA>      
#> 2          2 I wanted more … resp_031136… comple… "{\"sentime… FALSE  <NA>      
#> # ℹ 3 more variables: raw_response <list>, sentiment <chr>, theme <chr>

You can also build the same schema natively with foundryR’s foundry_schema() and schema_*() constructors when you would rather not depend on ellmer. See vignette("responses-api") for the native path, and vignette("content-safety") for using Azure Content Safety as a pipeline gate.

The practical rule is simple: use ellmer when you need the best R chat client, and use foundryR when you need Azure AI Foundry results as data – and use as_foundry_schema() when you want both.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.