| chat_aws_bedrock | R Documentation |
AWS Bedrock provides a number of language models, including those from Anthropic's Claude, using the Bedrock Converse API.
Authentication is handled through {paws.common}, so if authentication
does not work for you automatically, you'll need to follow the advice
at https://www.paws-r-sdk.com/#credentials. In particular, if your
org uses AWS SSO, you'll need to run aws sso login at the terminal.
Bedrock supports prompt caching via cache checkpoints. When caching is enabled, ellmer places cache checkpoints on the system prompt and the last turn, so that the conversation history is cached across turns.
By default (cache = "auto"), caching is enabled for models known to
support it (Anthropic Claude and Amazon Nova) and disabled for all other
models. You can also set cache to "5m" or "1h" to force a specific
TTL, or "none" to disable caching entirely. Note that individual models
may have minimum input token thresholds before caching takes effect.
Note that token_usage() does not currently reflect the cost of writing
to the cache, which is priced at a premium over regular input tokens.
Cache read savings are reported correctly.
chat_aws_bedrock(
system_prompt = NULL,
base_url = NULL,
model = NULL,
profile = NULL,
cache = c("auto", "5m", "1h", "none"),
params = NULL,
api_args = list(),
api_headers = character(),
echo = NULL
)
models_aws_bedrock(profile = NULL, base_url = NULL)
system_prompt |
A system prompt to set the behavior of the assistant. |
base_url |
The base URL to the API endpoint. |
model |
The model to use for the chat (defaults to "us.anthropic.claude-sonnet-4-6").
We regularly update the default, so we strongly recommend explicitly specifying a model for anything other than casual use.
Use While ellmer provides a default model, there's no guarantee that you'll
have access to it, so you'll need to specify a model that you can.
If you're using cross-region inference,
you'll need to use the inference profile ID, e.g.
|
profile |
AWS profile to use. |
cache |
How long to cache inputs? The default, See details below. |
params |
Common model parameters, usually created by |
api_args |
Named list of arbitrary extra arguments appended to the body
of every chat API call. Use api_args = list(
additionalModelRequestFields = list(
thinking = list(type = "enabled", budget_tokens = 4000)
)
)
See https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-call.html for more details. |
api_headers |
Named character vector of arbitrary extra headers appended to every chat API call. |
echo |
One of the following options:
Note this only affects the |
A Chat object.
Other chatbots:
chat_anthropic(),
chat_azure_openai(),
chat_cloudflare(),
chat_databricks(),
chat_deepseek(),
chat_github(),
chat_google_gemini(),
chat_groq(),
chat_huggingface(),
chat_lmstudio(),
chat_mistral(),
chat_ollama(),
chat_openai(),
chat_openai_compatible(),
chat_openrouter(),
chat_perplexity(),
chat_portkey(),
chat_posit()
## Not run:
# Basic usage
chat <- chat_aws_bedrock()
chat$chat("Tell me three jokes about statisticians")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.