ExLLM.Adapters.Bedrock (ex_llm v0.5.0)

View Source

AWS Bedrock adapter for ExLLM. Supports multiple providers including Claude, Titan, Llama, Cohere, AI21, and Mistral through Bedrock.

Configuration

The adapter supports multiple credential sources:

  1. Explicit credentials in configuration
  2. Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN)
  3. AWS profiles from ~/.aws/credentials
  4. EC2 instance metadata
  5. ECS task role credentials

Configuration options:

  • :access_key_id - AWS access key
  • :secret_access_key - AWS secret key
  • :session_token - AWS session token (optional)
  • :region - AWS region (defaults to "us-east-1")
  • :profile - AWS profile name
  • :model - Default model to use

Example Usage

messages = [
  %{role: "user", content: "Hello, how are you?"}
]

# Simple chat
{:ok, response} = ExLLM.Adapters.Bedrock.chat(messages)
IO.puts(response.content)

# Streaming chat
{:ok, stream} = ExLLM.Adapters.Bedrock.stream_chat(messages)
for chunk <- stream do
  if chunk.content, do: IO.write(chunk.content)
end

Available Models

Common model aliases:

  • "nova-lite" - Amazon Nova Lite (cost-effective default)
  • "nova-pro" - Amazon Nova Pro
  • "claude-opus-4" - Anthropic Claude 4 Opus
  • "claude-3-5-sonnet" - Anthropic Claude 3.5 Sonnet
  • "llama-3.3-70b" - Meta Llama 3.3 70B
  • "palmyra-x5" - Writer Palmyra X5
  • "deepseek-r1" - DeepSeek R1