Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

AWS Logo
Menu
Introducing AWSSDK.Extensions.Bedrock.MEAI

Introducing AWSSDK.Extensions.Bedrock.MEAI

The easiest way to implement GenAI into our .NET apps

Brandon Minnick
Amazon Employee
Published Mar 25, 2025
Last Modified Mar 31, 2025
Are you looking to add GenAI functionality to your .NET app? AWSSDK.Extensions.Bedrock.MEAI makes it easy.
Let's define what some of these words mean, then check out how to use this NuGet Package in our apps! You're also welcome to skip the definitions and jump directly to the code below.

What is MEAI?

"MEAI" in the package name is an acronym for Microsoft Extensions AI a new library that is now the recommended approach for all us .NET developers to integrate GenAI into our apps going forward.
Under the hood, MEAI provides an abstraction layer that allows us to easily swap GenAI tools and models while keeping the code in our business logic and unit tests exactly the same. If you're not already using Microsoft AI Extensions for .NET, I HIGHLY recommend implementing it; your future self will thank you. 💯

What is Bedrock?

"Bedrock" in the package name refers to Amazon Bedrock, an AWS service that provides us access to over 40+ foundation models from popular providers such as Anthropic, Meta, Mistral, DeepSeek and more.
Just for fun, let's ask the recently released Amazon Q Developer CLI, to get a better explanation:
Image not found
Using Amazon Q CLI to Define of Bedrock

Code

Now that we have those pesky definitions out of the way, let's create a .NET Console app that uses AWSSDK.Extensions.Bedrock.MEAI!
You can find the completed code sample here: https://github.com/TheCodeTraveler/Bedrock-MEAI-Sample
Next, add the AWSSDK.Extensions.Bedrock.MEAI NuGet Package to our app. If you're unfamiliar with adding NuGet Packages, you can find more information here.
Now we can finally write some code!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
using AiChatClient;
using Amazon;
using Amazon.BedrockRuntime;
using Microsoft.Extensions.AI;

IAmazonBedrockRuntime runtime = new AmazonBedrockRuntimeClient("Insert AwsCredentials AccessKeyId", "Insert AwsCredentials SecretAccessKey", RegionEndpoint.USEast1);
IChatClient client = runtime.AsChatClient(); // Abstraction provided by Microsoft.Extensions.AI

var chatMessage = new ChatMessage { Text = "Is this working?" };

await foreach (var response in client.GetStreamingResponseAsync(chatMessage, new() { ModelId = "anthropic.claude-v2" }))
{
Console.Write(response.Text);
}
Now let's click Run and see what happens 👀
Image not found
Terminal Output from AWSSDK.Extensions.Bedrock.MEAI
It works! And the crazy part is it only took a couple lines of code!
You can find the completed code sample here: https://github.com/TheCodeTraveler/Bedrock-MEAI-Sample

Conclusion

As .NET developers, we should all be leveraging the Microsoft AI Extensions for .NET when adding GenAI to our apps.
As new LLMs debut and as new GenAI services, like Amazon Bedrock continue to grow, we are all but guaranteed that we'll be swapping models and services in our production apps for the foreseeable future. But thanks to tools like AWSSDK.Extensions.Bedrock.MEAI,
Next, I'll be exploring how to use this to build a ChatGPT clone using AWSSDK.Extensions.Bedrock.MEAI + .NET MAUI. Make sure to subscribe to this blog and to watch this GitHub repo for the latest updates!
 

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

Comments

Log in to comment