Parallel API calls: Fixed Config, Multiple Messages
Source:R/LLM_parallel_utils.R
call_llm_broadcast.RdBroadcasts different messages using the same configuration in parallel.
Perfect for batch processing different prompts with consistent settings.
Use setup_llm_parallel() when you want explicit control over workers.
Value
A tibble with columns: message_index (metadata), the config
list-column (so llm_par_resume() can re-run failures), provider, model,
all model parameters, response_text, raw_response_json, success,
error_message, and the other diagnostics documented in call_llm_par().
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{
# Broadcast different questions
config <- llm_config(provider = "groq", model = "openai/gpt-oss-20b")
messages <- list(
list(list(role = "user", content = "What is 2+2?")),
list(list(role = "user", content = "What is 3*5?")),
list(list(role = "user", content = "What is 10/2?"))
)
setup_llm_parallel(workers = 4, verbose = TRUE)
results <- call_llm_broadcast(config, messages)
reset_llm_parallel(verbose = TRUE)
} # }