Parallel API calls: Multiple Configs, Fixed Message
Source:R/LLM_parallel_utils.R
call_llm_compare.RdCompares different configurations (models, providers, settings) using the same message.
Perfect for benchmarking across different models or providers.
Use setup_llm_parallel() when you want explicit control over workers.
Value
A tibble with columns: config_index (metadata), provider, model, all varying model parameters, response_text, raw_response_json, success, error_message.
Parallel Workflow
Recommended workflow:
Call
setup_llm_parallel()once at the start of your script.Run one or more parallel experiments (e.g.,
call_llm_broadcast()).Call
reset_llm_parallel()at the end to restore sequential processing. If the active future plan is sequential,call_llm_par()temporarily switches tomultisessionfor the duration of the call.
Examples
if (FALSE) { # \dontrun{
# Compare different models
config1 <- llm_config(provider = "openai", model = "gpt-5-nano")
config2 <- llm_config(provider = "groq", model = "openai/gpt-oss-20b")
configs_list <- list(config1, config2)
messages <- "Explain quantum computing"
setup_llm_parallel(workers = 4, verbose = TRUE)
results <- call_llm_compare(configs_list, messages)
reset_llm_parallel(verbose = TRUE)
} # }