GeminiDotnet 0.6.1
dotnet add package GeminiDotnet --version 0.6.1
NuGet\Install-Package GeminiDotnet -Version 0.6.1
<PackageReference Include="GeminiDotnet" Version="0.6.1" />
paket add GeminiDotnet --version 0.6.1
#r "nuget: GeminiDotnet, 0.6.1"
// Install GeminiDotnet as a Cake Addin #addin nuget:?package=GeminiDotnet&version=0.6.1 // Install GeminiDotnet as a Cake Tool #tool nuget:?package=GeminiDotnet&version=0.6.1
GeminiDotnet
This package provides the tools to interact with the Google Gemini models in .NET.
This package is lightweight, has no external dependencies, is Native AOT compatible, uses System.Text.Json for performant serialization, and provides a model directly mapping to the Google Gemini API's structure.
For an API you can use with other models and a more user-friendly API, you should consider interacting with this library through the GeminiDotnet.Extensions.AI
package, which exposes Microsoft.Extensions.AI.Abstractions
API implementations, including a full IChatClient
implementation. For more information about why this may be preferred, you can read the Microsoft.Extensions.AI
announcement blog post.
Getting Started
You can install this package into your project as follows.
dotnet add package GeminiDotnet
Then, you can create and use the GeminiClient
to interact with the Google Gemini API as follows.
using GeminiDotnet;
var options = new GeminiClientOptions
{
ApiKey = "<your-api-key>"
};
var client = new GeminiClient(options);
var request = new GenerateContentRequest
{
Contents =
[
new ChatMessage
{
Role = ChatRoles.User,
Parts = [new Part { Text = "Who was the first person to walk on the moon?" }]
}
]
};
await foreach (var result in client.GenerateContentStreamingAsync("gemini-2.0-flash", request, cancellationToken))
{
// Use the result as it is returned.
}
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. |
-
net9.0
- System.Net.ServerSentEvents (>= 9.0.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on GeminiDotnet:
Package | Downloads |
---|---|
GeminiDotnet.Extensions.AI
A lightweight, modern implementation of the Microsoft.Extensions.AI.Abstractions APIs for interacting with Google Gemini models. |
GitHub repositories
This package is not used by any popular GitHub repositories.