Last year, we announced the Google Gen AI SDK as the new unified library for Gemini on Google AI (via the Gemini Developer API) and Vertex AI (via the Vertex AI API). At the time, it was only a Python SDK. Since then, the team has been busy adding support for Go, Node.js, and **Java **but my favorite language, C#, was missing until now.
Today, I’m happy to announce that we now have a Google Gen AI .NET SDK! This …
Last year, we announced the Google Gen AI SDK as the new unified library for Gemini on Google AI (via the Gemini Developer API) and Vertex AI (via the Vertex AI API). At the time, it was only a Python SDK. Since then, the team has been busy adding support for Go, Node.js, and **Java **but my favorite language, C#, was missing until now.
Today, I’m happy to announce that we now have a Google Gen AI .NET SDK! This SDK enables C#/.NET developers use Gemini from Google AI or Vertex AI with a single unified library.
Let’s take a look at the details.
Installation
To install the library, run the following command in your .NET project directory:
Import it to your code as follows:
Create a client
First, you need to create a client to talk to Gemini.
You can target Gemini on Google AI (via the Gemini Developer API):
Or you can target Gemini on Vertex AI (via the Vertex AI API):
Generate text
Once you have the client, you can generate text with a unary response:
You can also generate text with a streaming response:
Generate image
Generating images is also straightforward with the new library:

Configuration
Of course, all of the text and image generation is highly configurable.
For example, you can define a response schema and a generation configuration with system instructions and other settings for text generation as follows:
Similarly, you can specify image generation configuration:
Posted in