set_model: Set Default Model

View source: R/model_defaults.R

set_modelR Documentation

Set Default Model

Description

Sets the package-wide default language model. Pass NULL to restore the built-in default ("openai:gpt-4o" unless overridden with options(aisdk.default_model = ...)). If new is omitted and runtime options are supplied, only the runtime options are updated.

Usage

set_model(
  new = NULL,
  context_window = NULL,
  max_output_tokens = NULL,
  max_tokens = NULL,
  thinking = NULL,
  thinking_budget = NULL,
  reasoning_effort = NULL,
  reset_options = FALSE
)

Arguments

new

A model identifier string, a LanguageModelV1 object, or NULL.

context_window

Optional context-window override used by sessions created from this default model.

max_output_tokens

Optional maximum output-token metadata override.

max_tokens

Optional default generation token limit.

thinking

Optional default thinking-mode value passed to providers that support it. Logical values are normalized by each provider.

thinking_budget

Optional default thinking budget.

reasoning_effort

Optional default reasoning effort ("low", "medium", or "high").

reset_options

Logical. If TRUE, clears default runtime options.

Value

Invisibly returns the previous default model.

Examples

old <- set_model("deepseek:deepseek-chat")
current <- get_model()
set_model(old)
set_model(NULL)

aisdk documentation built on May 29, 2026, 9:07 a.m.