DotnetGeminiSDK 1.0.7

There is a newer version of this package available.
See the version list below for details.
dotnet add package DotnetGeminiSDK --version 1.0.7
NuGet\Install-Package DotnetGeminiSDK -Version 1.0.7
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="DotnetGeminiSDK" Version="1.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotnetGeminiSDK --version 1.0.7
#r "nuget: DotnetGeminiSDK, 1.0.7"
#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 DotnetGeminiSDK as a Cake Addin
#addin nuget:?package=DotnetGeminiSDK&version=1.0.7

// Install DotnetGeminiSDK as a Cake Tool
#tool nuget:?package=DotnetGeminiSDK&version=1.0.7

DotnetGeminiSDK 🚀

Welcome to DotnetGeminiSDK, a .NET SDK for interacting with the Google Gemini API. This SDK empowers developers to harness the capabilities of machine learning models to generate creative content effortlessly.

Table of Contents

What is Google Gemini?

Google Gemini is an advanced AI platform that offers various interfaces for commands tailored to different use cases. It allows users to interact with machine learning models for generating content and responses to instructions. The platform supports free-form commands, structured commands, and chat-based requests. Additionally, Gemini provides the ability to adjust models for specific tasks, enhancing their performance for particular use cases.

Installation 📦

Get started by installing the DotnetGeminiSDK NuGet package. Run the following command in the NuGet Package Manager Console:

Install-Package DotnetGeminiSDK

Or, if you prefer using the .NET CLI:

dotnet add package DotnetGeminiSDK

Configuration ⚙️

To use the Gemini SDK, configure the GoogleGeminiConfig object. Add the Gemini client to your service collection using GeminiServiceExtensions:

using DotnetGeminiSDK;
using Microsoft.Extensions.DependencyInjection;

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddGeminiClient(config =>
        {
            config.ApiKey = "YOUR_GOOGLE_GEMINI_API_KEY";
            config.ImageBaseUrl = "CURRENTLY_IMAGE_BASE_URL";
            config.TextBaseUrl = "CURRENTLY_IMAGE_BASE_URL";
        });
    }
}

How to use? 🔎

Dependency Injection

When you incorporate the Gemini client, you can seamlessly inject it into your code for immediate use.

using DotnetGeminiSDK.Client.Interfaces;
using Microsoft.Extensions.DependencyInjection;

public class YourClass
{
    private readonly IGeminiClient _geminiClient;

    public YourClass(IGeminiClient geminiClient)
    {
        _geminiClient = geminiClient;
    }

    public async Task Example()
    {
        var response = await _geminiClient.TextPrompt("Text for processing");
        // Process the response as needed
    }
}

Usage 🚀

Text Prompt 📝

Prompt the Gemini API with a text message using the TextPrompt method:

var geminiClient = serviceProvider.GetRequiredService<IGeminiClient>();
var response = await geminiClient.TextPrompt("Write a story about a magic backpack");

Multiple Text Prompt 📚

Prompt the Gemini API with multiple text messages using the TextPrompt method with a list of Content objects:

var geminiClient = serviceProvider.GetRequiredService<IGeminiClient>();

var messages = new List<Content>
{
    new Content
    {
        Parts = new List<Part>
        {
            new Part
            {
                Text = "Write a story about a magic backpack"
            }
        }
    },
    // Add more Content objects as needed
};

var response = await geminiClient.TextPrompt(messages);

Image Prompt 🖼️

Using file

Prompt the Gemini API with an image and a text message using the ImagePrompt method:

var geminiClient = serviceProvider.GetRequiredService<IGeminiClient>();
var image = File.ReadAllBytes("path/to/your/image.jpg");
var response = await geminiClient.ImagePrompt("Describe this image", image, ImageMimeType.Jpeg);
Using Base64 String

Prompt the Gemini API with an base64 string and a text message using the ImagePrompt method:

var geminiClient = serviceProvider.GetRequiredService<IGeminiClient>();
var base64Image = "image-as-base64";
var response = await geminiClient.ImagePrompt("Describe this image", base64Image, ImageMimeType.Jpeg);

Contributing 🤝

Contributions are welcome! Feel free to open issues or pull requests to enhance the SDK.

License 📜

This project is licensed under the MIT License.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.14 181 4/25/2024
1.0.13 144 4/18/2024
1.0.12 1,122 3/17/2024
1.0.11 410 2/28/2024
1.0.10 86 2/28/2024
1.0.9 98 2/28/2024
1.0.8 91 2/28/2024
1.0.7 107 2/28/2024
1.0.6 151 2/27/2024
1.0.5 108 2/18/2024
1.0.4 145 2/18/2024
1.0.3 85 2/18/2024
1.0.2 145 2/18/2024
1.0.1 70 2/18/2024
1.0.0 84 2/18/2024