Skip to content

AWS Bedrock provides a number of language models, including those from Anthropic's Claude, using the Bedrock Converse API.

Authentication

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.

Usage

chat_bedrock(
  system_prompt = NULL,
  turns = NULL,
  model = NULL,
  profile = NULL,
  api_args = list(),
  echo = NULL
)

Arguments

system_prompt

A system prompt to set the behavior of the assistant.

turns

A list of Turns to start the chat with (i.e., continuing a previous conversation). If not provided, the conversation begins from scratch.

model

ellmer provides a default model, but you'll typically need to you'll specify a model that you actually have access to.

If you're using cross-region inference, you'll need to use the inference profile ID, e.g. model="us.anthropic.claude-3-5-sonnet-20240620-v1:0".

profile

AWS profile to use.

api_args

Named list of arbitrary extra arguments appended to the body of every chat API call. Some useful arguments include:

api_args = list(
  inferenceConfig = list(
    maxTokens = 100,
    temperature = 0.7,
    topP = 0.9,
    topK = 20
  )
)

echo

One of the following options:

  • none: don't emit any output (default when running in a function).

  • text: echo text output as it streams in (default when running at the console).

  • all: echo all input and output.

Note this only affects the chat() method.

Value

A Chat object.

Examples

if (FALSE) { # \dontrun{
# Basic usage
chat <- chat_bedrock()
chat$chat("Tell me three jokes about statisticians")
} # }