-
-
Notifications
You must be signed in to change notification settings - Fork 993
Description
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
- Use AWS IAM credentials - More complex setup, requires AWS SDK integration
- Use LiteLLM proxy - Current workaround, adds latency and complexity
- Use OpenRouter - Doesn't support private VPC deployments or EU-specific regions
Additional Context
- AWS Bedrock API Keys documentation: https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys-how.html
- Long-term keys are IAM service-specific credentials scoped only to Bedrock
- Keys can be set with expiration dates or never expire
- Bedrock is available in 10+ AWS regions globally
Implementation Notes
The provider implementation would need to:
- Handle Bearer token authentication (simpler than AWS SigV4)
- Support region-specific endpoints
- Map Bedrock's response format to OpenFang's internal format
- Handle streaming responses for real-time output
- 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