For example, with just a few lines of code, you can access Gemini's multimodal capabilities to generate text from text input:
using GoogleGenerativeAI;
var gen = new GenerativeAIService("YOUR_API_KEY");
var response = await gen.GenerateContentAsync("");
var firstPart = response.Candidates.FirstOrDefault().Content.Parts.FirstOrDefault();
Console.WriteLine(firstPart.Text);
This repository contains a sample app demonstrating how the SDK can access and utilize the Gemini model for various use cases.
-
Check out this repository.
git clone https://github.com/muniz/generative-ai-dotnet
-
Obtain an API key to use with the Google AI SDKs.
-
Open and build the solution(.sln) file of this repo.
-
Paste your API key into the
YOUR_API_KEY
property in theProgram
file. -
Run the app, put a your text input in console and click enter.
5ac78a46d0fd371fe98656b13d22c083.mp4
Find complete documentation for the Google AI SDKs and the Gemini model in the Google documentation:
https://ai.google.dev/docs