Skip to content

Feature Request: Add Amazon Bedrock as LLM Provider #209

@obue

Description

@obue

Summary

Add support for Amazon Bedrock as an LLM provider in OpenFang, with authentication via Bedrock's long-term API keys.

Motivation

Amazon Bedrock provides access to foundation models from leading AI companies (Anthropic Claude, Amazon Titan, Meta Llama, Cohere, AI21 Labs, Stability AI, and more) through a unified API. Many users prefer Bedrock for:

  • Unified access to multiple model providers through a single service
  • Enterprise features like VPC deployment, encryption, and compliance certifications
  • Regional availability including EU regions (eu-central-1, eu-west-1, etc.) for data residency requirements
  • Simplified billing through AWS consolidated billing

Currently, OpenFang supports 26 LLM providers but lacks Bedrock support, requiring users to set up proxy solutions like LiteLLM as a workaround.

Proposed Solution

Authentication

Support Bedrock's long-term API keys (introduced July 2024) using Bearer token authentication:

rust
// Example authentication header
Authorization: Bearer

API endpoint format:

https://bedrock-runtime.{region}.amazonaws.com/model/{model-id}/converse

Configuration Example

toml
[llm.bedrock]
enabled = true
api_key = "${AWS_BEARER_TOKEN_BEDROCK}"
region = "eu-central-1"
default_model = "eu.anthropic.claude-sonnet-4-6"

Supported Models

  • Anthropic Claude (Opus, Sonnet, Haiku)
  • Amazon Titan
  • Meta Llama
  • Cohere Command
  • AI21 Jurassic
  • Mistral AI
  • And more as AWS adds them

API Compatibility

Bedrock supports multiple API formats:

  • /converse - Unified conversation API (recommended)
  • /invoke - Model-specific invocation
  • Streaming via /invoke-with-response-stream

Alternatives Considered

  1. Use AWS IAM credentials - More complex setup, requires AWS SDK integration
  2. Use LiteLLM proxy - Current workaround, adds latency and complexity
  3. Use OpenRouter - Doesn't support private VPC deployments or EU-specific regions

Additional Context

Implementation Notes

The provider implementation would need to:

  1. Handle Bearer token authentication (simpler than AWS SigV4)
  2. Support region-specific endpoints
  3. Map Bedrock's response format to OpenFang's internal format
  4. Handle streaming responses for real-time output
  5. Support model-specific parameters (temperature, max_tokens, etc.)

Benefits

  • Native Bedrock support without proxy overhead
  • Better performance (direct API calls)
  • Simplified configuration for Bedrock users
  • Access to EU-hosted models for GDPR compliance
  • Enterprise-grade security and compliance features

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions