Compendium.Adapters.Bedrock 1.0.0-preview.0

This is a prerelease version of Compendium.Adapters.Bedrock.
dotnet add package Compendium.Adapters.Bedrock --version 1.0.0-preview.0
                    
NuGet\Install-Package Compendium.Adapters.Bedrock -Version 1.0.0-preview.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Compendium.Adapters.Bedrock" Version="1.0.0-preview.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Compendium.Adapters.Bedrock" Version="1.0.0-preview.0" />
                    
Directory.Packages.props
<PackageReference Include="Compendium.Adapters.Bedrock" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Compendium.Adapters.Bedrock --version 1.0.0-preview.0
                    
#r "nuget: Compendium.Adapters.Bedrock, 1.0.0-preview.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Compendium.Adapters.Bedrock@1.0.0-preview.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Compendium.Adapters.Bedrock&version=1.0.0-preview.0&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Compendium.Adapters.Bedrock&version=1.0.0-preview.0&prerelease
                    
Install as a Cake Tool

Compendium.Adapters.Bedrock

NuGet

AWS Bedrock implementation of Compendium's IAIProvider — one adapter, every hosted model family : Anthropic Claude, Meta Llama, Mistral, Amazon Nova, Amazon Titan, Cohere. Text completions (sync + streaming) flow through Bedrock's unified Converse / ConverseStream API; embeddings flow through InvokeModel with per-family payload shapes.

This adapter is for callers who want AWS data-residency, IAM-based access control, SigV4 auth, and Amazon's commercial terms — not the direct Anthropic API (see Compendium.Adapters.Anthropic for that).

Quick start

using Compendium.Abstractions.AI;
using Compendium.Abstractions.AI.Models;
using Compendium.Adapters.Bedrock.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();
services.AddLogging();
services.AddCompendiumBedrock(o =>
{
    o.Region = "us-east-1";
    o.DefaultModelId = "anthropic.claude-3-5-sonnet-20241022-v2:0";
    o.EmbeddingModelId = "amazon.titan-embed-text-v2:0";
    // Credentials default to the AWS SDK chain (env, profile, IAM role).
});

var sp = services.BuildServiceProvider();
var ai = sp.GetRequiredService<IAIProvider>();

var result = await ai.CompleteAsync(new CompletionRequest
{
    Model = "anthropic.claude-3-haiku-20240307-v1:0",
    Messages = new List<Message> { Message.User("Hello, Bedrock.") },
});

Console.WriteLine(result.Value.Content);

Run the sample :

AWS_REGION=us-east-1 dotnet run --project samples/01-chat-with-claude-via-bedrock

IAM policy

The runtime adapter needs only data-plane permissions :

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "BedrockRuntime",
      "Effect": "Allow",
      "Action": [
        "bedrock:Converse",
        "bedrock:ConverseStream",
        "bedrock:InvokeModel",
        "bedrock:InvokeModelWithResponseStream"
      ],
      "Resource": [
        "arn:aws:bedrock:*::foundation-model/*",
        "arn:aws:bedrock:*:*:inference-profile/*"
      ]
    }
  ]
}

Scope Resource down to specific model ARNs in production. The adapter does not require bedrock:ListFoundationModels — the model catalog is curated in-package.

Options

Property Default Notes
Region (required) e.g. us-east-1. Bedrock model availability varies by region.
AccessKey null Optional override. Prefer IAM roles in production.
SecretKey null Paired with AccessKey.
SessionToken null Optional STS session token for assumed-role credentials.
DefaultModelId anthropic.claude-3-5-sonnet-20241022-v2:0 Used when CompletionRequest.Model is null/blank.
EmbeddingModelId amazon.titan-embed-text-v2:0 Auto-detects Titan vs Cohere by id prefix.
DefaultMaxTokens 4096 Used when CompletionRequest.MaxTokens is null.
Timeout 120s Per-request timeout.
MaxRetries 3 AWS SDK retry attempts for transient errors.

Bind from IConfiguration :

{
  "Compendium": {
    "Adapters": {
      "Bedrock": {
        "Region": "us-east-1",
        "DefaultModelId": "anthropic.claude-3-5-sonnet-20241022-v2:0",
        "EmbeddingModelId": "amazon.titan-embed-text-v2:0"
      }
    }
  }
}
services.AddCompendiumBedrock(Configuration);

Model id routing

Bedrock's Converse API is family-agnostic — the adapter passes the model id through as-is. Use the canonical Bedrock id format :

  • anthropic.claude-3-5-sonnet-20241022-v2:0
  • anthropic.claude-3-haiku-20240307-v1:0 (cheapest Claude — great default for dev/CI)
  • meta.llama3-1-70b-instruct-v1:0
  • mistral.mistral-large-2407-v1:0
  • amazon.nova-pro-v1:0

Cross-region inference profiles work too :

  • us.anthropic.claude-3-5-sonnet-20241022-v2:0
  • eu.anthropic.claude-3-5-sonnet-20241022-v2:0

Embeddings auto-detect the family by id prefix :

  • amazon.titan-embed-* → Titan single-text per call, supports the dimensions hint.
  • cohere.embed-* → Cohere batch (one HTTP call for the whole input list), defaults to input_type = "search_document".

Unknown embedding ids fail fast with AI.InvalidRequest.

Billing & throughput

Bedrock offers two billing modes per model :

  1. On-demand — pay per token. The default; just call the adapter.
  2. Provisioned throughput — pay for reserved capacity by the hour. Set DefaultModelId to the provisioned model ARN (arn:aws:bedrock:...:provisioned-model/...) and the adapter routes there.

Prompt caching (currently Anthropic-only on Bedrock) is not yet exposed by this preview; it will land behind a BedrockOptions.EnablePromptCaching flag in a follow-up.

Data residency

All requests stay within the configured Region. Bedrock does not train on your prompts. For workloads with strict residency requirements, pick a region in the appropriate AWS partition (eu-central-1, ap-northeast-1, GovCloud, ...) and confirm model availability with aws bedrock list-foundation-models.

Production checklist

  • IAM role, not static access keys — use EKS pod identity or EC2 instance profile.
  • Region pinning — set Region explicitly; do not rely on the AWS SDK's AWS_REGION env var alone in multi-region deployments.
  • Scope IAM resources to specific model ARNs.
  • Set MaxRetries in line with your latency SLO — Bedrock returns 429 under load.
  • Log via ILogger<BedrockAIProvider> — turn it on for failed-request diagnostics.
  • Hook a health checkHealthCheckAsync() sends a 1-token probe.
  • Cap DefaultMaxTokens to avoid runaway costs from misbehaving callers.
  • Pin the model id — Bedrock occasionally retires legacy versions.

Tool calling & vision

Native Bedrock support for tool calling (ToolConfiguration) and vision (ImageBlock) is not exposed on the IAIProvider surface — that contract is text-only. The agent loop in Compendium.Application owns tool calling; a typed Bedrock-native client surfacing vision and tools will land in a follow-up preview.

Compatibility

Package version Compendium.Abstractions.AI AWSSDK.BedrockRuntime
1.0.0-preview.0 1.0.1 4.0.17.9

License

MIT — see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.0 49 5/18/2026