dsp_configure() builds an ellmer Chat for a provider and makes it the
default chat, like DSPy's dspy.configure(lm = ...). Modules use it when
neither the call nor the module names a chat; see get_default_chat()
for the full order.
Arguments
- provider
Character string specifying the provider. One of:
"openai","anthropic","google". IfNULL(default), uses the first provider whose API key is set:OPENAI_API_KEY,ANTHROPIC_API_KEY, thenGOOGLE_API_KEY.- model
Character string specifying the model name. If
NULL, uses the provider's default model.- api_key
Character string with the API key. If
NULL, reads from the appropriate environment variable.- temperature
Sampling temperature, applied through
ellmer::params(temperature = ). DefaultNULLuses the provider default. Reasoning models may ignore or reject it: gpt-6-luna accepts it only withparams = ellmer::params(reasoning_effort = "none").- ...
Additional arguments passed to the ellmer chat constructor (
ellmer::chat_openai(),ellmer::chat_anthropic()orellmer::chat_google_gemini()), such asparamsorsystem_prompt.
See also
Other configuration:
cache_stats(),
clear_cache(),
configure_cache(),
dsprrr_sitrep(),
get_default_chat(),
is_reasoning_model(),
with_lm()
Examples
if (FALSE) { # \dontrun{
# Configure with auto-detection (uses env vars)
dsp_configure()
# Configure with specific provider and model
dsp_configure(provider = "openai", model = "gpt-6-luna")
# Configure with temperature
dsp_configure(provider = "anthropic", temperature = 0.7)
# gpt-6-luna takes a temperature only with reasoning turned off
dsp_configure(
provider = "openai",
model = "gpt-6-luna",
temperature = 0,
params = ellmer::params(reasoning_effort = "none")
)
# Now run() uses this configuration
run(module(signature("question -> answer")), question = "What is 2+2?")
} # }