GeminiDotnet 0.4.0
See the version list below for details.
dotnet add package GeminiDotnet --version 0.4.0
NuGet\Install-Package GeminiDotnet -Version 0.4.0
<PackageReference Include="GeminiDotnet" Version="0.4.0" />
paket add GeminiDotnet --version 0.4.0
#r "nuget: GeminiDotnet, 0.4.0"
// Install GeminiDotnet as a Cake Addin #addin nuget:?package=GeminiDotnet&version=0.4.0 // Install GeminiDotnet as a Cake Tool #tool nuget:?package=GeminiDotnet&version=0.4.0
GeminiDotnet
This package provides the tools to interact with the Google Gemini models in .NET.
This package aims to be lightweight, with no dependencies and direct mappings to the Gemini API. For an API you can use
with other models, and for a nicer API, you should consider interacting with this library through the
GeminiDotnet.Extensions.AI
library, which exposes an
Microsoft.Extensions.AI.IChatClient
implementation. For more information about why this may be preferred, you can read the Microsoft.Extensions.AI
announcement blog post.
Getting Started
If you want to use the minimal API, 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 Gemini 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 = ChatRole.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 its 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.1)
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.