Rediger

Amazon Bedrock

Amazon Bedrock provides managed inference for foundation models through AWS. Agent Framework can wrap a Bedrock IChatClient or use the Python BedrockChatClient while keeping the standard agent, session, middleware, and tool APIs.

Important

Amazon Bedrock is a third-party system. Review AWS service terms, data handling, regional availability, model access, and usage costs before sending application data.

Install the packages

dotnet add package AWSSDK.Extensions.Bedrock.MEAI
dotnet add package Microsoft.Agents.AI --prerelease

Configuration

AWS_REGION="us-east-1"
BEDROCK_MODEL_ID="anthropic.claude-3-5-sonnet-20241022-v2:0"

Authentication uses the standard AWS credential chain, including environment variables, shared profiles, workload identity, and IAM roles.

Create the AWS Bedrock runtime client, convert it to IChatClient, and then create an Agent Framework agent.

var awsRegion = Environment.GetEnvironmentVariable("AWS_REGION") ?? "us-east-1";
var modelId = Environment.GetEnvironmentVariable("BEDROCK_MODEL_ID") ?? "anthropic.claude-3-5-sonnet-20241022-v2:0";
// Create the Bedrock runtime client.
var bedrockRuntime = new AmazonBedrockRuntimeClient(RegionEndpoint.GetBySystemName(awsRegion));
IChatClient chatClient = bedrockRuntime.AsIChatClient(modelId);
AIAgent agent = chatClient.AsAIAgent(
    instructions: "You are a helpful assistant.",
    name: "BedrockAgent");

AWS credentials follow the standard AWS credential chain. Grant only the Bedrock model actions the application needs.

Install the package

pip install agent-framework-bedrock --pre

Configuration

BEDROCK_REGION="us-east-1"
BEDROCK_CHAT_MODEL="anthropic.claude-3-5-sonnet-20241022-v2:0"
AWS_ACCESS_KEY_ID="<access-key>"
AWS_SECRET_ACCESS_KEY="<secret-key>"
# Optional temporary credentials:
AWS_SESSION_TOKEN="<session-token>"
# Optional shared profile:
AWS_PROFILE="<profile>"

BedrockChatClient reads the model, region, and AWS credentials from its settings or explicit constructor values.

async def main() -> None:
    """Run a Bedrock-backed agent with one tool call."""
    # 1. Create an agent with Bedrock chat client and one tool.
    agent = Agent(
        client=BedrockChatClient(),
        instructions="You are a concise travel assistant.",
        name="BedrockWeatherAgent",
        tools=[get_weather],
        default_options=BedrockChatOptions(tool_choice="auto"),
    )

    # 2. Run a query that uses the weather tool.
    query = "Use the weather tool to check the forecast for New York."
    print(f"User: {query}")
    response = await agent.run(query)
    print(f"Assistant: {response.text}")

Use BedrockChatOptions for Bedrock-specific request options and BedrockGuardrailConfig when your deployment uses Bedrock guardrails. The Python client forwards additionalModelRequestFields, guardrailConfig, performanceConfig, requestMetadata, and promptVariables to the Bedrock Converse API when you set them.

For non-streaming requests, the client omits guardrailConfig.streamProcessingMode because that field is valid only for ConverseStream. When the model ID is a Prompt Management ARN, define inference, system, tool, and additional model request fields on the managed prompt. Bedrock rejects those fields in the runtime request, so the client omits them; promptVariables remains available.

Send image input

BedrockChatClient sends data-backed images from user messages through the Bedrock Converse API when the selected model supports image input. Create the image content with Content.from_data() or a base64 data URI.

Bedrock accepts GIF, JPEG, PNG, and WebP images. The client doesn't send external image URLs, images from assistant-message history, or rich image content in tool results. Download an external image and pass its bytes when you need to send it to the model.

Generate embeddings

BedrockEmbeddingClient generates embeddings with Amazon Titan embedding models. Configure BEDROCK_EMBEDDING_MODEL and BEDROCK_REGION, then use the same AWS credential chain as BedrockChatClient.

No runnable Agent Framework embedding sample is currently published for this client.

Note

Amazon Bedrock integration isn't currently available for Agent Framework Go. See the Agent Framework Go repository for the latest status.

Tools

Bedrock supports locally invoked Agent Framework tools but doesn't expose provider-hosted tool factories.

Tool C# Python Notes
Function Tools ✅ ✅ Model support varies by the selected Bedrock model.
Tool Approval ✅ ✅ Applied by the Agent Framework function-invocation loop.
Code Interpreter ❌ ❌ No Bedrock-hosted code interpreter integration.
File Search ❌ ❌ No Bedrock-hosted file-search integration.
Web Search ❌ ❌ No Bedrock-hosted web-search integration.
Hosted MCP Tools ❌ ❌ No Bedrock-hosted MCP integration.
Local MCP Tools ✅ ✅ Runs in the application process.

Next steps