Amazon Bedrock
OpenClaw can use Amazon Bedrock models via pi‑ai’s Bedrock Converse streaming provider. Bedrock auth uses the AWS SDK default credential chain, not an API key.What pi-ai supports
- Provider:
amazon-bedrock - API:
bedrock-converse-stream - Auth: AWS credentials (env vars, shared config, or instance role)
- Region:
AWS_REGIONorAWS_DEFAULT_REGION(default:us-east-1)
Automatic model discovery
OpenClaw can automatically discover Bedrock models that support streaming and text output. Discovery usesbedrock:ListFoundationModels and is
cached (default: 1 hour).
How the implicit provider is enabled:
- If
models.bedrockDiscovery.enabledistrue, OpenClaw will try discovery even when no AWS env marker is present. - If
models.bedrockDiscovery.enabledis unset, OpenClaw only auto-adds the implicit Bedrock provider when it sees one of these AWS auth markers:AWS_BEARER_TOKEN_BEDROCK,AWS_ACCESS_KEY_ID+AWS_SECRET_ACCESS_KEY, orAWS_PROFILE. - The actual Bedrock runtime auth path still uses the AWS SDK default chain, so
shared config, SSO, and IMDS instance-role auth can work even when discovery
needed
enabled: trueto opt in.
models.bedrockDiscovery:
enableddefaults to auto mode. In auto mode, OpenClaw only enables the implicit Bedrock provider when it sees a supported AWS env marker.regiondefaults toAWS_REGIONorAWS_DEFAULT_REGION, thenus-east-1.providerFiltermatches Bedrock provider names (for exampleanthropic).refreshIntervalis seconds; set to0to disable caching.defaultContextWindow(default:32000) anddefaultMaxTokens(default:4096) are used for discovered models (override if you know your model limits).- For explicit
models.providers["amazon-bedrock"]entries, OpenClaw can still resolve Bedrock env-marker auth early from AWS env markers such asAWS_BEARER_TOKEN_BEDROCKwithout forcing full runtime auth loading. The actual model-call auth path still uses the AWS SDK default chain.
Onboarding
- Ensure AWS credentials are available on the gateway host:
- Add a Bedrock provider and model to your config (no
apiKeyrequired):
EC2 Instance Roles
When running OpenClaw on an EC2 instance with an IAM role attached, the AWS SDK can use the instance metadata service (IMDS) for authentication. For Bedrock model discovery, OpenClaw only auto-enables the implicit provider from AWS env markers unless you explicitly setmodels.bedrockDiscovery.enabled: true.
Recommended setup for IMDS-backed hosts:
- Set
models.bedrockDiscovery.enabledtotrue. - Set
models.bedrockDiscovery.region(or exportAWS_REGION). - You do not need a fake API key.
- You only need
AWS_PROFILE=defaultif you specifically want an env marker for auto mode or status surfaces.
bedrock:InvokeModelbedrock:InvokeModelWithResponseStreambedrock:ListFoundationModels(for automatic discovery)
AmazonBedrockFullAccess.
Quick setup (AWS path)
Notes
- Bedrock requires model access enabled in your AWS account/region.
- Automatic discovery needs the
bedrock:ListFoundationModelspermission. - If you rely on auto mode, set one of the supported AWS auth env markers on the
gateway host. If you prefer IMDS/shared-config auth without env markers, set
models.bedrockDiscovery.enabled: true. - OpenClaw surfaces the credential source in this order:
AWS_BEARER_TOKEN_BEDROCK, thenAWS_ACCESS_KEY_ID+AWS_SECRET_ACCESS_KEY, thenAWS_PROFILE, then the default AWS SDK chain. - Reasoning support depends on the model; check the Bedrock model card for current capabilities.
- If you prefer a managed key flow, you can also place an OpenAI‑compatible proxy in front of Bedrock and configure it as an OpenAI provider instead.
Guardrails
You can apply Amazon Bedrock Guardrails to all Bedrock model invocations by adding aguardrail object to the
amazon-bedrock plugin config. Guardrails let you enforce content filtering,
topic denial, word filters, sensitive information filters, and contextual
grounding checks.
guardrailIdentifier(required) accepts a guardrail ID (e.g.abc123) or a full ARN (e.g.arn:aws:bedrock:us-east-1:123456789012:guardrail/abc123).guardrailVersion(required) specifies which published version to use, or"DRAFT"for the working draft.streamProcessingMode(optional) controls whether guardrail evaluation runs synchronously ("sync") or asynchronously ("async") during streaming. If omitted, Bedrock uses its default behavior.trace(optional) enables guardrail trace output in the API response. Set to"enabled"or"enabled_full"for debugging; omit or set"disabled"for production.
bedrock:ApplyGuardrail
permission in addition to the standard invoke permissions.