Compendium.Adapters.Bedrock
1.0.0-preview.0
dotnet add package Compendium.Adapters.Bedrock --version 1.0.0-preview.0
NuGet\Install-Package Compendium.Adapters.Bedrock -Version 1.0.0-preview.0
<PackageReference Include="Compendium.Adapters.Bedrock" Version="1.0.0-preview.0" />
<PackageVersion Include="Compendium.Adapters.Bedrock" Version="1.0.0-preview.0" />
<PackageReference Include="Compendium.Adapters.Bedrock" />
paket add Compendium.Adapters.Bedrock --version 1.0.0-preview.0
#r "nuget: Compendium.Adapters.Bedrock, 1.0.0-preview.0"
#:package Compendium.Adapters.Bedrock@1.0.0-preview.0
#addin nuget:?package=Compendium.Adapters.Bedrock&version=1.0.0-preview.0&prerelease
#tool nuget:?package=Compendium.Adapters.Bedrock&version=1.0.0-preview.0&prerelease
Compendium.Adapters.Bedrock
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:0anthropic.claude-3-haiku-20240307-v1:0(cheapest Claude — great default for dev/CI)meta.llama3-1-70b-instruct-v1:0mistral.mistral-large-2407-v1:0amazon.nova-pro-v1:0
Cross-region inference profiles work too :
us.anthropic.claude-3-5-sonnet-20241022-v2:0eu.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 thedimensionshint.cohere.embed-*→ Cohere batch (one HTTP call for the whole input list), defaults toinput_type = "search_document".
Unknown embedding ids fail fast with AI.InvalidRequest.
Billing & throughput
Bedrock offers two billing modes per model :
- On-demand — pay per token. The default; just call the adapter.
- Provisioned throughput — pay for reserved capacity by the hour. Set
DefaultModelIdto 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
Regionexplicitly; do not rely on the AWS SDK'sAWS_REGIONenv var alone in multi-region deployments. - Scope IAM resources to specific model ARNs.
- Set
MaxRetriesin line with your latency SLO — Bedrock returns 429 under load. - Log via
ILogger<BedrockAIProvider>— turn it on for failed-request diagnostics. - Hook a health check —
HealthCheckAsync()sends a 1-token probe. - Cap
DefaultMaxTokensto 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 | Versions 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. |
-
net9.0
- AWSSDK.BedrockRuntime (>= 4.0.17.9)
- Compendium.Abstractions (>= 1.0.1)
- Compendium.Abstractions.AI (>= 1.0.1)
- Compendium.Core (>= 1.0.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.16)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.16)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.16)
- Microsoft.Extensions.Options (>= 9.0.16)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.16)
- Microsoft.Extensions.Options.DataAnnotations (>= 9.0.16)
- System.Text.Json (>= 9.0.16)
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 |