AWS Bedrock
Hermes Agent 原生支持把 Amazon Bedrock 作为 provider 使用,并且接的是 Converse API,不是 OpenAI 兼容接口。这意味着你可以完整使用 Bedrock 生态:IAM 认证、Guardrails、跨区域 inference profiles,以及所有 foundation models。
前置条件
- AWS credentials —— 任何 boto3 credential chain 支持的来源都可以:
- IAM instance role(EC2、ECS、Lambda,无需额外配置)
AWS_ACCESS_KEY_ID+AWS_SECRET_ACCESS_KEY环境变量AWS_PROFILE(用于 SSO 或命名 profile)- 本地开发时使用
aws configure
- boto3 —— 通过
pip install hermes-agent[bedrock]安装 - IAM 权限 —— 至少需要:
bedrock:InvokeModel和bedrock:InvokeModelWithResponseStream(用于推理)bedrock:ListFoundationModels和bedrock:ListInferenceProfiles(用于模型发现)
如果你运行在 AWS 计算环境中,只需给实例或任务挂上带 AmazonBedrockFullAccess 的 IAM role 即可。无需 API key,也不需要配置 .env。Hermes 会自动识别实例角色。
快速开始
# Install with Bedrock support
pip install hermes-agent[bedrock]
# Select Bedrock as your provider
hermes model
# → Choose "More providers..." → "AWS Bedrock"
# → Select your region and model
# Start chatting
hermes chat
配置
运行 hermes model 后,你的 ~/.hermes/config.yaml 中会出现类似内容:
model:
default: us.anthropic.claude-sonnet-4-6
provider: bedrock
base_url: https://bedrock-runtime.us-east-2.amazonaws.com
bedrock:
region: us-east-2
区域
AWS 区域会按以下优先级解析(从高到低):
config.yaml中的bedrock.regionAWS_REGION环境变量AWS_DEFAULT_REGION环境变量- 默认值:
us-east-1
Guardrails
如果你想把 Amazon Bedrock Guardrails 应用到所有模型调用上,可以这样配置:
bedrock:
region: us-east-2
guardrail:
guardrail_identifier: "abc123def456" # From the Bedrock console
guardrail_version: "1" # Version number or "DRAFT"
stream_processing_mode: "async" # "sync" or "async"
trace: "disabled" # "enabled", "disabled", or "enabled_full"
模型发现
Hermes 会通过 Bedrock control plane 自动发现可用模型。你也可以自定义发现行为:
bedrock:
discovery:
enabled: true
provider_filter: ["anthropic", "amazon"] # Only show these providers
refresh_interval: 3600 # Cache for 1 hour
可用模型
Bedrock 在按需调用时使用的是 inference profile ID。hermes model 选择器会自动展示这些 ID,并把推荐模型放在最上面:
| Model | ID | Notes |
|---|---|---|
| Claude Sonnet 4.6 | us.anthropic.claude-sonnet-4-6 | 推荐,速度与能力平衡最好 |
| Claude Opus 4.6 | us.anthropic.claude-opus-4-6-v1 | 能力最强 |
| Claude Haiku 4.5 | us.anthropic.claude-haiku-4-5-20251001-v1:0 | Claude 系列中最快 |
| Amazon Nova Pro | us.amazon.nova-pro-v1:0 | Amazon 旗舰模型 |
| Amazon Nova Micro | us.amazon.nova-micro-v1:0 | 最快、最便宜 |
| DeepSeek V3.2 | deepseek.v3.2 | 很强的开放模型 |
| Llama 4 Scout 17B | us.meta.llama4-scout-17b-instruct-v1:0 | Meta 最新系列 |
以 us. 为前缀的模型使用的是跨区域 inference profile,通常拥有更好的容量,并能在 AWS 区域之间自动故障切换。以 global. 为前缀的模型则会在全球所有可用区域中进行路由。
在会话中切换模型
你可以在对话中直接使用 /model:
/model us.amazon.nova-pro-v1:0
/model deepseek.v3.2
/model us.anthropic.claude-opus-4-6-v1
诊断
hermes doctor
doctor 会检查:
- AWS credentials 是否可用(环境变量、IAM role、SSO)
boto3是否已安装- Bedrock API 是否可访问(
ListFoundationModels) - 当前区域里可用模型的数量
Gateway(消息平台)
Bedrock 能和所有 Hermes 网关平台配合使用(Telegram、Discord、Slack、Feishu 等)。只要把 Bedrock 配成 provider,然后像平常一样启动 gateway:
hermes gateway setup
hermes gateway start
gateway 会读取 config.yaml,并使用同一套 Bedrock provider 配置。
故障排除
"No API key found" / "No AWS credentials"
Hermes 会按以下顺序查找凭据:
AWS_BEARER_TOKEN_BEDROCKAWS_ACCESS_KEY_ID+AWS_SECRET_ACCESS_KEYAWS_PROFILE- EC2 instance metadata(IMDS)
- ECS container credentials
- Lambda execution role
如果这些都不存在,请运行 aws configure,或者给你的 AWS 计算实例绑定 IAM role。
"Invocation of model ID ... with on-demand throughput isn't supported"
请使用 inference profile ID(带 us. 或 global. 前缀),而不是裸 foundation model ID。例如:
- ❌
anthropic.claude-sonnet-4-6 - ✅
us.anthropic.claude-sonnet-4-6
"ThrottlingException"
这表示你碰到了 Bedrock 针对该模型的限流。Hermes 会自动使用退避重试。如果你需要更高额度,请到 AWS Service Quotas console 申请提升配额。