Skip to content

Bearer Token / API Key Authentication for chat_aws_bedrock() #1002

@Tazinho

Description

@Tazinho

Hi Hadley, just ran into the issue that I couldn't natively request our internal Bedrock endpoints which rely on Bearer Token authentication (API key via Authorization: Bearer <key> header, no SigV4 signing). I built a workaround using httr2 as a proof of concept, but of course I'm losing all ellmer features like streaming, tool calling, etc. Is this something that could be resolved on the ellmer side? I believe it has quite some impact for enterprise users behind API gateways. Let me know in case you need any further info.

Problem

chat_aws_bedrock() requires IAM credentials via paws.common, which doesn't support the Bearer Token authentication that AWS Bedrock launched in July 2025. This prevents users who access Bedrock through enterprise API gateways (which issue API keys instead of IAM credentials) from using ellmer natively.

Reproduction

Sys.setenv(AWS_BEARER_TOKEN_BEDROCK = "my-api-key")

chat <- chat_aws_bedrock(
  base_url = "https://my-company-gateway.example.com/bedrock",
  model = "us.anthropic.claude-sonnet-4-5-20250929-v1:0"
)
# Error: No IAM credentials found.

Python's boto3 supports this via AWS_BEARER_TOKEN_BEDROCK — it skips SigV4 signing and sends Authorization: Bearer <key> instead.

Proposal

Add a credentials parameter (similar to chat_azure_openai()) that, when provided:

  1. Skips paws.common IAM credential resolution
  2. Sends the key as Authorization: Bearer <key> header
  3. Does not apply SigV4 signing
# Desired API
chat <- chat_aws_bedrock(
  base_url = "https://my-company-gateway.example.com/bedrock",
  model = "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
  credentials = "my-api-key"
)

Workaround

Currently requires calling the Bedrock Converse API directly via httr2, losing all ellmer features (streaming, tool calling, parallel_chat(), etc.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions