This unofficial (RestEase based) client enables working with the Google Gemini REST Interface (https://ai.google.dev/gemini-api/docs)
$ dotnet add package Google-GenAI.SDKUnofficial RestEase C# Client for Google Gemini.
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.Development.json", optional: true)
.Build();
services.AddGoogleGeminiSDK(configuration);
var serviceProvider = services.BuildServiceProvider();
var api = serviceProvider.GetRequiredService<IGenerativeLanguageApi>();
var result = await api.GenerateContentAsync("gemini-2.0-flash", new GenerateContentRequest
{
Contents =
[
new Content
{
Parts =
[
new Part
{
Text = "Explain how AI works in a few words"
}
]
}
]
}, cancellationToken);