Mscc.GenerativeAI.Microsoft
2.8.22
See the version list below for details.
dotnet add package Mscc.GenerativeAI.Microsoft --version 2.8.22
NuGet\Install-Package Mscc.GenerativeAI.Microsoft -Version 2.8.22
<PackageReference Include="Mscc.GenerativeAI.Microsoft" Version="2.8.22" />
<PackageVersion Include="Mscc.GenerativeAI.Microsoft" Version="2.8.22" />
<PackageReference Include="Mscc.GenerativeAI.Microsoft" />
paket add Mscc.GenerativeAI.Microsoft --version 2.8.22
#r "nuget: Mscc.GenerativeAI.Microsoft, 2.8.22"
#:package Mscc.GenerativeAI.Microsoft@2.8.22
#addin nuget:?package=Mscc.GenerativeAI.Microsoft&version=2.8.22
#tool nuget:?package=Mscc.GenerativeAI.Microsoft&version=2.8.22
MSCC GenerativeAI for .NET integrating with Microsoft.Extensions.AI and Microsoft Semantic Kernel.
Integrate Gemini API into your .NET applications using Microsoft.Extensions.AI.
This package implements the IChatClient, IEmbeddingGenerator and IImageGenerator interfaces offering a unified experience for .NET applications and libraries.
Benefits of Microsoft.Extensions.AI
Microsoft.Extensions.AI offers a unified API abstraction for AI services, similar to our successful logging and dependency injection (DI) abstractions. Our goal is to provide standard implementations for caching, telemetry, tool calling, and other common tasks that work with any provider.
Read more Introducing Microsoft.Extensions.AI Preview – Unified AI Building Blocks for .NET
Getting started
To get started, you can create a console application and install the Mscc.GenerativeAI.Microsoft package.
Have your API key from Google AI Studio and you're ready to go.
Chat
Microsoft.Extensions.AI provides abstractions and exchange types for working with AI services. The Google.GenAI library includes an implementation of the IChatClient interface to enable easy integration with applications that use these abstractions.
using Microsoft.Extensions.AI;
using Mscc.GenerativeAI.Microsoft;
// Chat with Gemini API.
var apiKey = Environment.GetEnvironmentVariable("GOOGLE_API_KEY");
var model = "gemini-2.5-flash";
var prompt = "What is AI?";
IChatClient chatClient = new GeminiChatClient(apiKey, model);
var response = await chatClient.CompleteAsync(prompt);
Console.WriteLine(response.Message);
response = await chatClient.CompleteAsync(
"Translate the following text into Pig Latin: I love .NET and AI");
Console.WriteLine(response.Message);
using Microsoft.Extensions.AI;
using Mscc.GenerativeAI.Microsoft;
using System.ComponentModel
// assuming credentials are set up in environment variables as instructed above.
IChatClient chatClient = new GeminiChatClient().AsIChatClient("gemini-2.5-flash")
.AsBuilder()
.UseFunctionInvocation()
.UseOpenTelemetry()
.Build();
ChatOptions options = new()
{
Tools = [AIFunctionFactory.Create(([Description("The name of the person whose age is to be retrieved")] string personName) => personName switch
{
"Alice" => 30,
"Bob" => 25,
_ => 35
}, "get_person_age", "Gets the age of the specified person");
};
await foreach (var update in chatClient.GetStreamingResponseAsync("How much older is Alice than Bob?", options))
{
Console.Write(update);
}
Embeddings
using Microsoft.Extensions.AI;
using Mscc.GenerativeAI.Microsoft;
// Create embeddings using the appropriate model.
var apiKey = Environment.GetEnvironmentVariable("GOOGLE_API_KEY");
var model = "text-embedding-004";
var prompt = "What is AI?";
IEmbeddingGenerator<string,Embedding<float>> generator =
new GeminiEmbeddingGenerator(apiKey, model);
var embeddings = await generator.GenerateAsync([prompt]);
Console.WriteLine(string.Join(", ", embeddings[0].Vector.ToArray()));
More examples
The folders samples and tests contain more examples.
Troubleshooting
tba
Feedback
You can create issues at the https://github.com/mscraftsman/generative-ai repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- JsonSchema.Net.Generation (>= 5.0.0)
- Microsoft.Bcl.AsyncInterfaces (>= 9.0.10)
- Microsoft.Extensions.AI.Abstractions (>= 9.10.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.10)
- Microsoft.Extensions.Http (>= 9.0.10)
- Microsoft.Extensions.Logging (>= 9.0.10)
- Microsoft.Extensions.Options (>= 9.0.10)
- Mscc.GenerativeAI (>= 2.8.22)
- Nullable (>= 1.3.1)
- System.Text.Encodings.Web (>= 9.0.10)
- System.Text.Json (>= 9.0.10)
-
net8.0
- JsonSchema.Net.Generation (>= 5.0.0)
- Microsoft.Extensions.AI.Abstractions (>= 9.10.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.10)
- Microsoft.Extensions.Http (>= 9.0.10)
- Microsoft.Extensions.Logging (>= 9.0.10)
- Microsoft.Extensions.Options (>= 9.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.10)
- Mscc.GenerativeAI (>= 2.8.22)
- System.Text.Encodings.Web (>= 9.0.10)
- System.Text.Json (>= 9.0.10)
-
net9.0
- JsonSchema.Net.Generation (>= 5.0.0)
- Microsoft.Extensions.AI.Abstractions (>= 9.10.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.10)
- Microsoft.Extensions.Http (>= 9.0.10)
- Microsoft.Extensions.Logging (>= 9.0.10)
- Microsoft.Extensions.Options (>= 9.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.10)
- Mscc.GenerativeAI (>= 2.8.22)
- System.Text.Json (>= 9.0.10)
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 |
|---|---|---|
| 2.8.24 | 54 | 11/2/2025 |
| 2.8.23 | 106 | 10/31/2025 |
| 2.8.22 | 130 | 10/30/2025 |
| 2.8.21 | 215 | 10/29/2025 |
| 2.8.20 | 210 | 10/28/2025 |
| 2.8.19 | 893 | 10/20/2025 |
| 2.8.18 | 363 | 10/17/2025 |
| 2.8.17 | 445 | 10/13/2025 |
| 2.8.16 | 532 | 10/8/2025 |
| 2.8.15 | 552 | 10/2/2025 |
| 2.8.14 | 531 | 9/30/2025 |
| 2.8.13 | 268 | 9/29/2025 |
| 2.8.12 | 314 | 9/26/2025 |
| 2.8.11 | 233 | 9/25/2025 |
| 2.8.10 | 437 | 9/22/2025 |
| 2.8.9 | 1,485 | 9/12/2025 |
| 2.8.8 | 147 | 9/12/2025 |
| 2.8.7 | 421 | 9/9/2025 |
| 2.8.5 | 172 | 9/9/2025 |
| 2.8.4 | 201 | 9/8/2025 |
| 2.8.3 | 841 | 8/28/2025 |
| 2.8.2 | 1,320 | 8/26/2025 |
| 2.8.1 | 239 | 8/26/2025 |
| 2.8.0 | 206 | 8/25/2025 |
| 2.7.1 | 197 | 8/20/2025 |
| 2.7.0 | 396 | 8/18/2025 |
| 2.6.13 | 161 | 8/16/2025 |
| 2.6.12 | 98 | 8/15/2025 |
| 2.6.11 | 92 | 8/15/2025 |
| 2.6.10 | 102 | 8/15/2025 |
| 2.6.9 | 879 | 8/8/2025 |
| 2.6.8 | 618 | 7/21/2025 |
| 2.6.7 | 472 | 7/16/2025 |
| 2.6.6 | 209 | 7/15/2025 |
| 2.6.5 | 157 | 7/11/2025 |
| 2.6.4 | 394 | 6/26/2025 |
| 2.6.3 | 1,979 | 6/5/2025 |
| 2.6.2 | 281 | 6/3/2025 |
| 2.6.1 | 237 | 5/26/2025 |
| 2.6.0 | 182 | 5/23/2025 |
| 2.5.6 | 590 | 5/16/2025 |
| 2.5.5 | 395 | 5/8/2025 |
| 2.5.4 | 149 | 5/8/2025 |
| 2.5.3 | 428 | 4/28/2025 |
| 2.5.2 | 224 | 4/19/2025 |
| 2.5.1 | 91 | 4/19/2025 |
| 2.5.0 | 455 | 4/11/2025 |
| 2.4.1 | 432 | 4/2/2025 |
| 2.4.0 | 535 | 3/25/2025 |
| 2.3.6 | 792 | 3/16/2025 |
| 2.3.5 | 152 | 3/16/2025 |
| 2.3.4 | 217 | 3/12/2025 |
| 2.3.3 | 168 | 3/12/2025 |
| 2.3.2 | 162 | 3/8/2025 |
| 2.3.1 | 140 | 3/8/2025 |
| 2.3.0 | 232 | 3/7/2025 |
| 2.2.11 | 2,173 | 2/27/2025 |
| 2.2.10 | 91 | 2/26/2025 |
| 2.2.9 | 163 | 2/24/2025 |
| 2.2.8 | 120 | 2/24/2025 |
| 2.2.7 | 163 | 2/20/2025 |
| 2.2.6 | 97 | 2/20/2025 |
| 2.2.5 | 117 | 2/18/2025 |
| 2.2.4 | 131 | 2/17/2025 |
| 2.2.3 | 888 | 2/13/2025 |
| 2.2.2 | 121 | 2/12/2025 |
| 2.2.1 | 100 | 2/11/2025 |
| 2.2.0 | 133 | 2/7/2025 |
| 2.1.8 | 113 | 2/7/2025 |
| 2.1.7 | 95 | 2/6/2025 |
| 2.1.6 | 222 | 2/3/2025 |
| 2.1.5 | 106 | 2/3/2025 |
| 2.1.4 | 84 | 2/3/2025 |
| 2.1.3 | 246 | 1/28/2025 |
| 2.1.2 | 185 | 1/27/2025 |
| 2.1.1 | 309 | 1/17/2025 |
| 2.1.0 | 76 | 1/16/2025 |
| 2.0.2-preview | 101 | 1/6/2025 |
| 2.0.1-preview | 217 | 12/11/2024 |
| 2.0.0-preview | 96 | 12/11/2024 |
| 1.9.7-preview | 87 | 12/6/2024 |
| 1.9.6-preview | 90 | 11/26/2024 |
| 1.9.5-preview | 90 | 11/22/2024 |
| 1.9.4 | 116 | 11/21/2024 |
| 1.9.3 | 94 | 11/20/2024 |
| 1.9.2 | 97 | 11/18/2024 |
| 1.9.1 | 115 | 11/13/2024 |
| 1.9.0-preview | 86 | 11/4/2024 |
| 1.8.3-preview | 83 | 11/1/2024 |
| 1.8.2-preview | 86 | 10/31/2024 |
# Changelog (Release Notes)
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
### Changed
### Fixed
## 2.8.22
### Changed
- bump version
## 2.8.21
### Added
- add implementation of `IImageGenerator` as `GeminiImageGenerator` (2366e37)
### Changed
- provide another example using newer Gemini models (fe2b7b8)
- refactor to provide lazily-initialized metadata (4714360)
## 2.8.20
### Changed
- bump version
## 2.8.19
### Changed
## 2.8.18
### Changed
- bump version
## 2.8.17
### Changed
- bump version
## 2.8.16
### Changed
- Update IChatClient to utilize newer surface area (0377aa1)
- bump version
## 2.8.15
### Changed
- bump version
## 2.8.14
### Changed
- bump version
## 2.8.13
### Changed
- bump version
## 2.8.12
### Changed
- bump version
## 2.8.11
### Changed
- bump version
## 2.8.10
### Changed
- bump version
## 2.8.9
### Changed
- bump version
## 2.8.8
### Added
- add `virtual` modifier (c9cf1e7)
### Changed
- change Fact to Theory and use OP's prompt #90 (c3e9832)
- change scope (a93811a)
- change namespace (f0a4254)
- update test case #90 [skip ci] (06dfa17)
### Fixed
- fix #90: add type mapping in streaming (fb67fd1)
## 2.8.7
### Changed
- bump version
### Fixed
- use named parameter
## 2.8.6
### Changed
- bump version
## 2.8.5
### Added
- Merge pull request #106 from TeodorVecerdi/feature/meai-function-calling (2920962)
### Changed
- Improve M.E.AI support for function calls (9e2b1f4)
- bump version
## 2.8.4
### Added
- implement function calling properly @TeodorVecerdi (7d441bf)
- add tests for function calling (bad4bfd)
### Changed
- bump version
## 2.8.3
### Changed
- bump version
## 2.8.2
### Changed
- bump version
## 2.8.1
### Changed
- bump version
## 2.8.0
### Changed
- bump version
## 2.7.1
### Changed
- bump version
## 2.7.0
### Changed
- Pass `Timeout` through #79
- bump version
## 2.6.13
### Changed
- bump version
## 2.6.12
### Changed
- no code changes
## 2.6.11
### Changed
- bump version
## 2.6.10
### Changed
- bump version
## 2.6.9
### Changed
- bump version
## 2.6.8
### Changed
## 2.6.7
### Changed
- Structured output support for Mscc.GenerativeAI.Microsoft [#97](https://github.com/mscraftsman/generative-ai/pull/97) thanks to @bharathm03
## 2.6.6
### Changed
- bump version
## 2.6.5
### Changed
- bump version
- update NuGet packages
## 2.6.4
### Changed
- bump version
## 2.6.3
### Added
- add fluent approach for `GeminiClient` with extension methods
- add constructor for GenerativeModel instance
## 2.6.2
### Changed
- bump version
## 2.6.1
### Changed
- bump version
## 2.6.0
### Changed
- Update to stable Microsoft.Extensions.AI and update some implementation [#87](https://github.com/mscraftsman/generative-ai/pull/87) thanks to @stephentoub
## 2.5.6
### Changed
- Update Microsoft.Extensions.AI version to 9.5.0-preview.1.25262.9
## 2.5.5
### Changed
- Update Microsoft.Extensions.AI version to 9.4.3-preview.1.25230.7 [85](https://github.com/mscraftsman/generative-ai/pull/85) thanks to @MackinnonBuck
## 2.5.4
### Changed
- bump version
## 2.5.3
### Changed
- bump version
## 2.5.2
### Changed
- bump version
## 2.5.1
### Changed
- bump version
## 2.5.0
### Changed
- bump version
## 2.4.1
### Changed
- bump version
## 2.4.0
### Changed
- bump version
## 2.3.6
### Changed
- bump version
## 2.3.5
### Changed
- bump version
## 2.3.4
### Changed
- Update to M.E.AI 9.3.0-preview.1.25161.3 [#72](https://github.com/mscraftsman/generative-ai/pull/72) thanks to @stephentoub
- bump version
## 2.3.3
### Changed
- bump version
## 2.3.2
### Changed
- bump version
## 2.3.1
### Changed
- use named parameter to initialize Vertex AI
- bump version
## 2.3.0
### Changed
- update NuGet packages
- bump version
## 2.2.11
### Changed
- bump version
## 2.2.10
### Changed
- bump version
## 2.2.9
### Changed
- bump version
## 2.2.8
### Changed
- bump version
## 2.2.7
### Changed
- bump version
## 2.2.6
### Changed
- bump version
## 2.2.5
### Changed
- update NuGet packages
- bump version
## 2.2.4
### Changed
- refactor namespace
- Update Microsoft.Extensions.AI to 9.3.0-preview.1.25114.11 [#67](https://github.com/mscraftsman/generative-ai/pull/67) thanks to @stephentoub
- update NuGet packages
- bump version
## 2.2.3
### Changed
- bump version
## 2.2.2
### Changed
- update NuGet packages
## 2.2.1
### Changed
- bump version
## 2.2.0
### Changed
- bump version
## 2.1.8
### Changed
- bump version
## 2.1.7
### Changed
- bump version
## 2.1.6
### Changed
- bump version
## 2.1.5
### Changed
- bump version
## 2.1.4
### Changed
- bump version
## 2.1.3
### Changed
- bump version
## 2.1.2
### Changed
- bump version
## 2.1.1
### Changed
- bump version
## 2.1.0
### Changed
- update M.E.AI to 9.1.0-preview.1.25064.3 [#58](https://github.com/mscraftsman/generative-ai/pull/58) thanks to @stephentoub
- update NuGet packages
- drop .NET 6.0 targeting
## 2.0.2
### Changed
- remove non-existent `ResponseSchema` mapping
- bump version
## 2.0.1
### Changed
- bump version
## 2.0.0
### Changed
## 1.9.7
### Changed
- bump version
## 1.9.6
### Changed
- use explicit/aliases namespace
- update NuGet packages
## 1.9.5
### Changed
- Update M.E.AI to 9.0.1-preview.1.24570.5 [#48](https://github.com/mscraftsman/generative-ai/pull/48) thanks to @stephentoub
## 1.9.4
### Changed
- bump version
## 1.9.3
### Changed
- bump version
## 1.9.2
### Changed
- bump version
## 1.9.1
### Changed
- PR: Update Microsoft.Extensions.AI to 9.0.0-preview.9.24556.5 [#44](https://github.com/mscraftsman/generative-ai/pull/44) thanks to @stephentoub
## 1.9.0
### Changed
- bump version
## 1.8.3
### Changed
- bump version
## 1.8.2
### Added
- initial release