GeminiDotnet 0.6.1

dotnet add package GeminiDotnet --version 0.6.1                
NuGet\Install-Package GeminiDotnet -Version 0.6.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GeminiDotnet" Version="0.6.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GeminiDotnet --version 0.6.1                
#r "nuget: GeminiDotnet, 0.6.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
0.6.1 46 2/18/2025
0.6.0 41 2/18/2025
0.5.0 51 2/17/2025
0.4.1 69 2/16/2025
0.4.0 78 2/15/2025
0.3.0 71 2/10/2025
0.2.0 63 2/9/2025
0.1.2 71 1/23/2025
0.1.1 76 1/23/2025
0.1.0 69 1/23/2025