aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • Software Engineering

Introducing Google Gen AI .NET SDK

  • aster.cloud
  • October 24, 2025
  • 2 minute read

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.


Partner with aster.cloud
for your next big idea.
Let us know here.



From our partners:

CITI.IO :: Business. Institutions. Society. Global Political Economy.
CYBERPOGO.COM :: For the Arts, Sciences, and Technology.
DADAHACKS.COM :: Parenting For The Rest Of Us.
ZEDISTA.COM :: Entertainment. Sports. Culture. Escape.
TAKUMAKU.COM :: For The Hearth And Home.
ASTER.CLOUD :: From The Cloud And Beyond.
LIWAIWAI.COM :: Intelligence, Inside and Outside.
GLOBALCLOUDPLATFORMS.COM :: For The World's Computing Needs.
FIREGULAMAN.COM :: For The Fire In The Belly Of The Coder.
ASTERCASTER.COM :: Supra Astra. Beyond The Stars.
BARTDAY.COM :: Prosperity For Everyone.

Let’s take a look at the details. 

Installation

To install the library, run the following command in your .NET project directory:

dotnet add package Google.GenAI

Import it to your code as follows:

using Google.GenAI;

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):

using Google.GenAI;
​
// Gemini Developer API
var client = new Client(apiKey: apiKey);

Or you can target Gemini on Vertex AI (via the Vertex AI API):

// Vertex AI API
var client = new Client(
project: project, location: location, vertexAI: true
)

Generate text

Once you have the client, you can generate text with a unary response:

var response = await client.Models.GenerateContentAsync(
model: "gemini-2.5-flash", contents: "why is the sky blue?"
);
Console.WriteLine(response.Candidates[0].Content.Parts[0].Text);

You can also generate text with a streaming response:

await foreach (var chunk in client.Models.GenerateContentStreamAsync(
model: "gemini-2.5-flash",
contents: "why is the sky blue?"
)) {
Console.WriteLine(chunk.Candidates[0].Content.Parts[0].Text);
}

Generate image

Generating images is also straightforward with the new library:

var response = await client.Models.GenerateImagesAsync(
model: "imagen-3.0-generate-002",
prompt: "Red skateboard"
);

// Save the image to a file
var image = response.GeneratedImages.First().Image;
await File.WriteAllBytesAsync("skateboard.jpg", image.ImageBytes);

Configuration

Of course, all of the text and image generation is highly configurable. 

Read More  Automating Data Pipelines With BigQuery And Fivetran

For example, you can define a response schema and a generation configuration with system instructions and other settings for text generation as follows:

// Define a response schema
Schema countryInfo = new()
{
Properties = new Dictionary<string, Schema> {
{
"name", new Schema { Type = Type.STRING, Title = "Name" }
},
{
"population", new Schema { Type = Type.INTEGER, Title = "Population" }
},
{
"capital", new Schema { Type = Type.STRING, Title = "Capital" }
},
{
"language", new Schema { Type = Type.STRING, Title = "Language" }
}
},
PropertyOrdering = ["name", "population", "capital", "language"],
Required = ["name", "population", "capital", "language"],
Title = "CountryInfo",
Type = Type.OBJECT
};

// Define a generation config
GenerateContentConfig config = new()
{
ResponseSchema = countryInfo,
ResponseMimeType = "application/json",
SystemInstruction = new Content
{
Parts = [
new Part {Text = "Only answer questions on countries. For everything else, say I don't know."}
]
},
MaxOutputTokens = 1024,
Temperature = 0.1,
TopP = 0.8,
TopK = 40,
};

var response = await client.Models.GenerateContentAsync(
model: "gemini-2.5-flash",
contents: "Give me information about Cyprus",
config: config);

Similarly, you can specify image generation configuration:

GenerateImagesConfig config = new()
{
NumberOfImages = 1,
AspectRatio = "1:1",
SafetyFilterLevel = SafetyFilterLevel.BLOCK_LOW_AND_ABOVE,
PersonGeneration = PersonGeneration.DONT_ALLOW,
IncludeSafetyAttributes = true,
IncludeRaiReason = true,
OutputMimeType = "image/jpeg",
};

var response = await client.Models.GenerateImagesAsync(
model: "imagen-3.0-generate-002",
prompt: "Red skateboard",
config: config
);

Conclusion

In this blog post, we introduced the Google Gen AI .NET SDK as the new unified SDK to talk to Gemini.

Here are some links to learn more:

DemoApp with samples on Live API and more

API reference

Source code on GitHub

Source: zedreviews.com


For enquiries, product placements, sponsorships, and collaborations, connect with us at [email protected]. We'd love to hear from you!

Our humans need coffee too! Your support is highly appreciated, thank you!

aster.cloud

Related Topics
  • .NET
  • Dotnet
  • google
You May Also Like
View Post
  • Software Engineering

Embedded Swift Improvements Coming in Swift 6.3

  • November 22, 2025
Visual Studio Code
View Post
  • Software Engineering

Visual Studio 2026 is here: faster, smarter, and a hit with early adopters

  • November 12, 2025
View Post
  • Software Engineering

Julia 1.12 Highlights

  • October 13, 2025
View Post
  • Engineering
  • Software Engineering

Development gets better with Age

  • October 9, 2025
View Post
  • Software Engineering

The Growth of the Swift Server Ecosystem

  • September 27, 2025
men with computer website information and chat bubbles vector illustration
View Post
  • Software
  • Software Engineering

What is an ISV (independent software vendor)?

  • August 27, 2025
aster-cloud-erp-bill_of_materials_2
View Post
  • Software
  • Software Engineering

What is an SBOM (software bill of materials)?

  • July 2, 2025
View Post
  • Software Engineering
  • Technology

Claude 3.7 Sonnet and Claude Code

  • February 25, 2025

Stay Connected!
LATEST
  • 1
    IBM Study: One in Four Malicious Breaches are AI-Enabled, Costing Companies $6 Million on Average
    • July 29, 2026
  • 2
    Accelerating the frontiers of scientific discovery: Google’s $40M commitment to the Genesis Mission
    • July 26, 2026
  • 3
    3 Questions: Neural transparency and the future of AI design
    • July 17, 2026
  • 4
    Intel Invests €5 Billion to Expand Manufacturing in Europe
    • July 13, 2026
  • 5
    IBM and Red Hat Expand Lightwell with New Offerings to Build the Trust Infrastructure for AI-Era Open Source
    • July 8, 2026
  • 6
    When I Was Young
    • July 4, 2026
  • 7
    The Fastest AI Fried Chicken In The World
    • June 29, 2026
  • 8
    Zed Approves | How to Stay Cool in Extreme Heat
    • June 29, 2026
  • 9
    The AI investment surge hasn’t produced the expected results yet. That could change in 2026
    • June 26, 2026
  • 10
    Zed Approves | It’s Prime Day 2026! Time to Upgrade Your World Cup Viewing Setup and Beat the Heat
    • June 25, 2026
about
Hello World!

We are aster.cloud. We’re created by programmers for programmers.

Our site aims to provide guides, programming tips, reviews, and interesting materials for tech people and those who want to learn in general.

We would like to hear from you.

If you have any feedback, enquiries, or sponsorship request, kindly reach out to us at:

[email protected]
Most Popular
  • 1
    Zed Approves | The Best Prime Day PC Deals: Top Gaming Rigs, Workstations, and Everyday Laptops
    • June 24, 2026
  • neon-cart 2
    Zed Approves: How to Gear Up for GTA 6 This Amazon Prime Day (2026 Quick Guide)
    • June 22, 2026
  • zedreviews-valerion 3
    Father’s Day Outdoors – Build Dad the Ultimate Backyard Watch Party
    • June 20, 2026
  • zedreviews-fathers-day-50830 4
    Father’s Day Outdoors, Round Two – Gear for the Action, the Tailgate, and Beating the Heat
    • June 20, 2026
  • zedreviews-fathers-day-2147684744 5
    The Ultimate Father’s Day Gift Guide – Home Entertainment Upgrades Dad Actually Wants
    • June 20, 2026
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.