Skip to main content

Overview

The AWS Bedrock provider enables ZeroClaw to use foundation models via AWS Bedrock’s Converse API. It uses AWS Signature Version 4 (SigV4) authentication with support for EC2 instance metadata, ECS container credentials, and environment variables. Provider ID: bedrock Alias: aws-bedrock Service: bedrock (for SigV4 signing) Endpoint: https://bedrock-runtime.{region}.amazonaws.com API: Converse API

Authentication

Environment Variables

Credentials are resolved in the following order:
  1. Environment variables:
    • AWS_ACCESS_KEY_ID (required)
    • AWS_SECRET_ACCESS_KEY (required)
    • AWS_SESSION_TOKEN (optional, for temporary credentials)
    • AWS_REGION or AWS_DEFAULT_REGION (default: us-east-1)
  2. ECS container credentials:
    • AWS_CONTAINER_CREDENTIALS_RELATIVE_URI (ECS/Fargate)
    • AWS_CONTAINER_CREDENTIALS_FULL_URI (ECS Anywhere)
    • AWS_CONTAINER_AUTHORIZATION_TOKEN (if required)
  3. EC2 instance metadata (IMDSv2):
    • Fetches temporary credentials from instance IAM role
    • Requires network access to 169.254.169.254

Credential Caching

Credentials are cached for 50 minutes to reduce metadata service calls:
The provider automatically refreshes credentials when they expire.

Configuration

Config File

Note: Bedrock does not use a single API key. Use AWS environment variables.

Environment Setup

Cross-Region Inference

Use cross-region inference profiles:

Features

Native Tool Calling

Supported: Yes Bedrock’s Converse API uses a nested tool format:

Vision Support

Supported: Yes Images are sent as base64-encoded bytes:
Image format is auto-detected from MIME type:
  • image/pngpng
  • image/gifgif
  • image/webpwebp
  • Others → jpeg

Prompt Caching

Supported: Yes Bedrock uses cachePoint blocks for prompt caching:

System Prompt Caching

System prompts larger than 3KB are automatically cached:

Conversation Caching

Conversations with more than 4 non-system messages cache the last message:

Streaming Support

Supported: Yes Use the converse-stream endpoint for real-time responses:
Streaming uses AWS EventStream binary format.

Token Usage Tracking

Supported: Yes Usage data is extracted from response:

API Endpoints

Converse

Endpoint: POST /model/{modelId}/converse Model ID Format: anthropic.claude-sonnet-4-6 or us.anthropic.claude-* Request:
Response:

Converse Stream

Endpoint: POST /model/{modelId}/converse-stream Response: AWS EventStream binary format with contentBlockDelta events.

Request Configuration

Max Tokens

Default: 4096 Configured via inferenceConfig.maxTokens.

Temperature

Range: 0.0 - 1.0 Default: 0.7 (from config)

Timeouts

  • Request timeout: 120 seconds
  • Connection timeout: 10 seconds

Message Format

System Blocks

Sent as array of blocks:

User Messages

Text only:
With images:

Assistant Messages

Text only:
With tool calls:

Tool Results

Sent as user message with toolResult blocks:
Multiple tool results are merged into a single user message.

AWS SigV4 Signing

Signature Process

  1. Create canonical request
  2. Create string to sign
  3. Derive signing key
  4. Calculate signature

Canonical URI

Model IDs with colons (e.g., v1:0) are percent-encoded:

Authorization Header

Session Token

For temporary credentials (STS, ECS, EC2):

Stop Reasons

Normalized stop reasons:

Error Handling

Authentication Errors

Solution: Export AWS credentials.

Region Errors

Default region is us-east-1. Override with:

Model Not Found

Ensure model ID matches Bedrock format:

Provider Capabilities

Model Discovery

Bedrock does not provide a public models endpoint. Use AWS CLI:
Or check the Bedrock model catalog.

Example Usage

Simple Chat

With Tools

With Vision

Streaming

EC2 Instance Setup

For EC2 instances, attach an IAM role with Bedrock permissions:
No environment variables needed — credentials auto-load from instance metadata.

ECS/Fargate Setup

For ECS tasks, assign a task IAM role with Bedrock permissions. The provider automatically fetches credentials from the ECS metadata endpoint.

Limitations

  • Max tokens is fixed at 4096 (not configurable per request)
  • Credential refresh is automatic (50-minute TTL)
  • Cross-region inference requires specific model ID format
  • No public model discovery endpoint
  • CRC validation is skipped for EventStream (relies on TLS)