Abstract interface for language models. All LLM providers must implement this class.
Uses do_ prefix for internal methods to prevent direct usage by end-users.
specification_versionThe version of this specification.
providerThe provider identifier (e.g., "openai").
model_idThe model identifier (e.g., "gpt-4o").
capabilitiesModel capability flags (e.g., is_reasoning_model).
new()Initialize the model with provider and model ID.
LanguageModelV1$new(provider, model_id, capabilities = list())providerProvider name.
model_idModel ID.
capabilitiesOptional list of capability flags.
has_capability()Check if model has a specific capability.
LanguageModelV1$has_capability(cap)capCapability name (e.g., "is_reasoning_model").
Logical.
generate()Public generation method (wrapper for do_generate).
LanguageModelV1$generate(...)...Call options passed to do_generate.
A GenerateResult object.
stream()Public streaming method (wrapper for do_stream).
LanguageModelV1$stream(callback, ...)callbackFunction to call with each chunk.
...Call options passed to do_stream.
A GenerateResult object.
do_generate()Generate text (non-streaming). Abstract method.
LanguageModelV1$do_generate(params)paramsA list of call options.
A GenerateResult object.
do_stream()Generate text (streaming). Abstract method.
LanguageModelV1$do_stream(params, callback)paramsA list of call options.
callbackA function called for each chunk (text, done).
A GenerateResult object (accumulated from the stream).
format_tool_result()Format a tool execution result for the provider's API.
LanguageModelV1$format_tool_result(tool_call_id, tool_name, result_content)tool_call_idThe ID of the tool call.
tool_nameThe name of the tool.
result_contentThe result content from executing the tool.
A list formatted as a message for this provider's API.
get_history_format()Get the message format used by this model's API for history.
LanguageModelV1$get_history_format()A character string ("openai" or "anthropic").
clone()The objects of this class are cloneable with this method.
LanguageModelV1$clone(deep = FALSE)deepWhether to make a deep clone.