GemiNet 1.0.3
dotnet add package GemiNet --version 1.0.3
NuGet\Install-Package GemiNet -Version 1.0.3
<PackageReference Include="GemiNet" Version="1.0.3" />
<PackageVersion Include="GemiNet" Version="1.0.3" />
<PackageReference Include="GemiNet" />
paket add GemiNet --version 1.0.3
#r "nuget: GemiNet, 1.0.3"
#addin nuget:?package=GemiNet&version=1.0.3
#tool nuget:?package=GemiNet&version=1.0.3
GemiNet
Gemini Developer API client for .NET and Unity
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
- This library does not currently support Vertex AI. If you want to use Vertex AI, please use Google.Cloud.AIPlatform.V1 instead.
License
This library is released under the MIT License.
Product | Versions 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. |
-
.NETStandard 2.1
- System.Net.Http.Json (>= 8.0.0)
- System.Text.Json (>= 8.0.5)
-
net6.0
- System.Net.Http.Json (>= 8.0.0)
- System.Text.Json (>= 8.0.5)
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
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.