View source: R/provider_custom.R
| create_custom_provider | R Documentation |
Creates a dynamic wrapper around existing model classes (OpenAI, Anthropic)
based on user-provided configuration. The returned provider can be registered
in the global ProviderRegistry.
create_custom_provider(
provider_name,
base_url,
api_key = NULL,
api_format = c("chat_completions", "responses", "anthropic_messages"),
use_max_completion_tokens = FALSE,
disable_stream_options = TRUE,
supports_native_tools = FALSE
)
provider_name |
The identifier name for this custom provider (e.g. "my_custom_openai_proxy"). |
base_url |
The base URL for the API endpoint. |
api_key |
The API key for authentication. If NULL, defaults to checking environmental variables. |
api_format |
The underlying API format to use. Supports "chat_completions" (OpenAI default), "responses" (OpenAI Responses API), and "anthropic_messages" (Anthropic Messages API). |
use_max_completion_tokens |
A boolean flag. If TRUE, injects the |
disable_stream_options |
A boolean flag. If TRUE, omit OpenAI-style
|
supports_native_tools |
A boolean flag. If FALSE, do not send native
OpenAI/Anthropic tool definitions or tool-result message formats. The SDK
will fall back to text-embedded |
A custom provider object with a language_model(model_id) method.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.