Files
Ren Finlayson 539852f81c
Some checks are pending
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
dotnet-build-and-test / paths-filter (push) Waiting to run
dotnet-build-and-test / dotnet-build-and-test (Debug, windows-latest, net9.0) (push) Blocked by required conditions
dotnet-build-and-test / dotnet-build-and-test (Release, integration, true, ubuntu-latest, net10.0) (push) Blocked by required conditions
dotnet-build-and-test / dotnet-build-and-test (Release, integration, true, windows-latest, net472) (push) Blocked by required conditions
dotnet-build-and-test / dotnet-build-and-test (Release, ubuntu-latest, net8.0) (push) Blocked by required conditions
dotnet-build-and-test / dotnet-build-and-test-check (push) Blocked by required conditions
test
2026-01-24 03:05:12 +11:00
..
2026-01-24 03:05:12 +11:00
2026-01-24 03:05:12 +11:00
2026-01-24 03:05:12 +11:00

Creating an AIAgent with Google Gemini

This sample demonstrates how to create an AIAgent using Google Gemini models as the underlying inference service.

The sample showcases two different IChatClient implementations:

  1. Google GenAI - Using the official Google.GenAI package
  2. Mscc.GenerativeAI.Microsoft - Using the community-driven Mscc.GenerativeAI.Microsoft package

Prerequisites

Before you begin, ensure you have the following prerequisites:

Set the following environment variables:

$env:GOOGLE_GENAI_API_KEY="your-google-api-key"  # Replace with your Google AI Studio API key
$env:GOOGLE_GENAI_MODEL="gemini-2.5-fast"  # Optional, defaults to gemini-2.5-fast

Package Options

Google GenAI (Official)

The official Google GenAI package provides direct access to Google's Generative AI models. This sample uses the AsIChatClient() extension method to convert the Google client to an IChatClient.

Mscc.GenerativeAI.Microsoft (Community)

The community-driven Mscc.GenerativeAI.Microsoft package provides a ready-to-use IChatClient implementation for Google Gemini models through the GeminiChatClient class.