Skip to content

hermes agent AWS Bedrock

Hermes Agent 使用 Converse API 原生支持 Amazon Bedrock —— 不是 OpenAI 兼容 endpoint。这让你可以完整访问 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 环境变量
    • 用于 SSO 或 named profiles 的 AWS_PROFILE
    • 本地开发使用 aws configure
  • boto3 —— 使用以下命令安装:

    Terminal window
    pip install hermes-agent[bedrock]
  • IAM permissions —— 至少需要:

    • bedrock:InvokeModelbedrock:InvokeModelWithResponseStream(用于 inference)
    • bedrock:ListFoundationModelsbedrock:ListInferenceProfiles(用于 model discovery)
Terminal window
# 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 region(优先级从高到低):

  1. config.yaml 中的 bedrock.region
  2. AWS_REGION 环境变量
  3. AWS_DEFAULT_REGION 环境变量
  4. 默认值:us-east-1

要将 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 自动发现可用模型。你可以自定义 discovery:

bedrock:
discovery:
enabled: true
provider_filter: ["anthropic", "amazon"] # Only show these providers
refresh_interval: 3600 # Cache for 1 hour

Bedrock 模型使用 inference profile IDs 进行按需调用。hermes model 选择器会自动显示这些模型,并将推荐模型放在顶部:

模型ID备注
Claude Sonnet 4.6us.anthropic.claude-sonnet-4-6推荐 —— 速度与能力的最佳平衡
Claude Opus 4.6us.anthropic.claude-opus-4-6-v1最强能力
Claude Haiku 4.5us.anthropic.claude-haiku-4-5-20251001-v1:0最快的 Claude
Amazon Nova Prous.amazon.nova-pro-v1:0Amazon 的旗舰模型
Amazon Nova Microus.amazon.nova-micro-v1:0最快、最便宜
DeepSeek V3.2deepseek.v3.2强大的开放模型
Llama 4 Scout 17Bus.meta.llama4-scout-17b-instruct-v1:0Meta 的最新模型

在对话中使用 /model 命令:

/model us.amazon.nova-pro-v1:0
/model deepseek.v3.2
/model us.anthropic.claude-opus-4-6-v1
Terminal window
hermes doctor

doctor 会检查:

  • AWS credentials 是否可用(env vars、IAM role、SSO)
  • 是否已安装 boto3
  • Bedrock API 是否可访问(ListFoundationModels
  • 你所在区域中可用模型的数量

Bedrock 可与所有 Hermes gateway 平台一起使用(Telegram、Discord、Slack、飞书等)。将 Bedrock 配置为你的 provider,然后正常启动 gateway:

Terminal window
hermes gateway setup
hermes gateway start

gateway 会读取 config.yaml,并使用相同的 Bedrock provider 配置。

Hermes 会按以下顺序检查 credentials:

  1. AWS_BEARER_TOKEN_BEDROCK
  2. AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY
  3. AWS_PROFILE
  4. EC2 instance metadata(IMDS)
  5. ECS container credentials
  6. Lambda execution role

如果都没有找到,请运行 aws configure,或为你的 compute instance 附加 IAM role。

"Invocation of model ID ... with on-demand throughput isn't supported"

Section titled “"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

你已经触达 Bedrock 的单模型 rate limit。Hermes 会自动使用 backoff 进行重试。要提高限制,请在 AWS Service Quotas 控制台中请求 quota increase。

如果想在 EC2 上使用 CloudFormation 进行完全自动化部署:

sample-hermes-agent-on-aws-with-bedrock —— 创建 VPC、IAM role、EC2 instance,并自动配置 Bedrock。可在任意区域一键部署。

-
0:000:00