GemiNet 1.0.3

dotnet add package GemiNet --version 1.0.3
                    
NuGet\Install-Package GemiNet -Version 1.0.3
                    
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="GemiNet" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GemiNet" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="GemiNet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GemiNet --version 1.0.3
                    
#r "nuget: GemiNet, 1.0.3"
                    
#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.
#addin nuget:?package=GemiNet&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=GemiNet&version=1.0.3
                    
Install as a Cake Tool

GemiNet

Gemini Developer API client for .NET and Unity

NuGet Releases GitHub license

English | 日本語

Overview

GemiNet is a Gemini Developer API client library for .NET/Unity. It is designed based on the official TypeScript SDK (js-genai), and provides an easy-to-use API compared to other libraries (Google_GenerativeAI, GeminiSharp, etc.). GemiNet also offers extension packages compatible with Microsoft.Extensions.AI abstraction layer, enabling smoother integration with your applications.

Installation

NuGet packages

GemiNet requires .NET Standard 2.1 or later. The package is available on NuGet.

.NET CLI

dotnet add package GemiNet

Package Manager

Install-Package GemiNet

Unity

You can use GemiNet in Unity by using NuGetForUnity. For details, please refer to the NuGetForUnity README.

Quick Start

You can call the Gemini API using GoogleGenAI.

using GemiNet;

using var ai = new GoogleGenAI
{
    ApiKey = Environment.GetEnvironmentVariable("GEMINI_API_KEY"),
};

var response = await ai.Models.GenerateContentAsync(new()
{
    Model = Models.Gemini2_0Flash,    // models/gemini-2.0-flash
    Contents = "Hello, Gemini!"
});

Console.WriteLine(response.GetText());

Streaming generation is also supported.

var request = new GenerateContentRequest
{
    Model = Models.Gemini2_0Flash,
    Contents = "Hello, Gemini!"
};

await foreach (var response in GenerateContentStreamAsync(request))
{
    Console.WriteLine(response.GetText());
}

Features

GemiNet's GoogleGenAI is modularized similar to the TypeScript SDK.

  • ai.Models allows you to generate content, generate vectors, and retrieve available models.
  • ai.Caches lets you create caches for specific inputs.
  • ai.Files enables file uploads and deletions.
  • ai.Live supports the Live API (bidirectional communication via WebSocket). For details, see the Live API section.

Live API

GemiNet supports the Live API. You can read messages using ReceiveAsync() with await foreach.

using GemiNet;

using var ai = new GoogleGenAI();

await using var session = await ai.Live.ConnectAsync(new()
{
    Model = Models.Gemini2_0FlashLive,
    Config = new()
    {
        ResponseModalities = [Modality.Text]
    }
});

_ = Task.Run(async () =>
{
    await session.SendRealtimeInputAsync(new()
    {
        Text = "Hello, Gemini!"
    });
});

await foreach (var message in session.ReceiveAsync())
{
    Console.WriteLine(message.ServerContent?.ModelTurn?.Parts[0].Text);
}

Microsoft.Extensions.AI

To use GemiNet with Microsoft.Extensions.AI, add the GemiNet.Extensions.AI package.

Installation

.NET CLI
dotnet add package GemiNet.Extensions.AI
Package Manager
Install-Package GemiNet.Extensions.AI

Usage

You can convert GoogleGenAI to Microsoft.Extensions.AI interfaces using AsChatClient() and AsEmbeddingGenerator().

using GemiNet;
using GemiNet.Extensions.AI;

using var ai = new GoogleGenAI();

var client = ai.AsChatClient(Models.Gemini2_0Flash);
var response = await client.GetResponseAsync([new(ChatRole.User, "What is AI?")]);

var embeddingGenerator = ai.AsEmbeddingGenerator(Models.Gemini2_0Flash);
var embedding = await embeddingGenerator.GenerateEmbeddingAsync("Hello, Gemini!");

Limitations

License

This library is released under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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 GemiNet:

Package Downloads
GemiNet.Extensions.AI

GemiNet Microsoft.Extensions.AI extensions

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 151 6/1/2025
1.0.2 123 5/30/2025
1.0.0 134 5/30/2025