![]() |
VOOZH | about |
dotnet add package Google_GenerativeAI.Tools --version 3.6.6
NuGet\Install-Package Google_GenerativeAI.Tools -Version 3.6.6
<PackageReference Include="Google_GenerativeAI.Tools" Version="3.6.6" />
<PackageVersion Include="Google_GenerativeAI.Tools" Version="3.6.6" />Directory.Packages.props
<PackageReference Include="Google_GenerativeAI.Tools" />Project file
paket add Google_GenerativeAI.Tools --version 3.6.6
#r "nuget: Google_GenerativeAI.Tools, 3.6.6"
#:package Google_GenerativeAI.Tools@3.6.6
#addin nuget:?package=Google_GenerativeAI.Tools&version=3.6.6Install as a Cake Addin
#tool nuget:?package=Google_GenerativeAI.Tools&version=3.6.6Install as a Cake Tool
A comprehensive toolkit to seamlessly integrate and structure your Google Gemini function calls in C#. Google_GenerativeAI.Tools is offered as part of the Google_GenerativeAI SDK, supporting multiple modes of usage: either through reflection-based approaches or via code generation.
Google_GenerativeAI.Tools streamlines how you define, discover, and call your functions for Google Gemini.
Key features:
Install the NuGet package (assuming it's available on NuGet.org):
dotnet add package Google.GenerativeAI.Tools
Reference the package in your project file:
<ItemGroup>
<PackageReference Include="Google.GenerativeAI.Tools" Version="x.x.x" />
</ItemGroup>
Restore packages:
dotnet restore
This method depends on runtime inspection of methods or delegates to generate the schema and create function tools.
Pros
Cons
JsonSerializerContext) for NativeAOT.Use [QuickTool] or [QuickTools] to define reflection-based tools:
public record StudentRecord
{
public string StudentId { get; set; }
public string FullName { get; set; }
// ...
}
// Reflection-based delegate
var func = (async ([Description("Query to retrieve student record")] string fullName) =>
{
// Implementation detail
return new StudentRecord
{
StudentId = "12345",
FullName = fullName
};
});
// Create QuickTool
var quickFt = new QuickTool(func, "GetStudentRecordAsync", "Returns the student record");
var model = new GenerativeModel(/* your config */);
model.AddFunctionTool(quickFt);
// Usage
var result = await model.GenerateContentAsync("What's the student record for John Joe?");
Console.WriteLine(result.Text());
Code generation automatically produces schemas and extension methods, saving you from manually dealing with reflection or serializer contexts.
Pros
Cons
Decorate your methods with [FunctionTool] to generate the needed schemas and integrate them:
[FunctionTool(GoogleFunctionTool = true)]
[Description("Retrieves content of a specific book page")]
public static Task<string> GetBookPageContentAsync(
string bookName,
int pageNumber,
CancellationToken cancellationToken = default)
{
// Implementation
return Task.FromResult($"Page {pageNumber} of {bookName}");
}
//Usage
var tools = new Tools([GetBookPageContentAsync]);
generativeModel.AddFunctionTool(tools);
Generated code will handle JSON schema definitions and produce extension methods to register with your GenerativeModel.
Build an interface to define one or more related methods. The code generator scans [GenerateJsonSchema] attributes to build tooling and registration code:
[GenerateJsonSchema(GoogleFunctionTool = true)]
public interface IWeatherFunctions
{
[Description("Get current weather in a location")]
Weather GetCurrentWeather(
[Description("City and state, e.g. San Francisco, CA")]
string location,
Unit unit = Unit.Celsius);
// ...
}
public class WeatherService : IWeatherFunctions
{
public Weather GetCurrentWeather(string location, Unit unit = Unit.Celsius)
{
return new Weather
{
Location = location,
Temperature = 20,
Unit = unit
};
}
}
// Register after code generation
var weatherService = new WeatherService();
var googleTool = weatherService.AsGoogleFunctionTool();
model.AddFunctionTool(googleTool);
Interface Grouping
Group multiple functions in one interface, effectively creating a reusable βplugin.β
| Aspect | Reflection-Based | Code Generator-Based |
|---|---|---|
| Setup Complexity | Low (quick prototyping) | Moderate (attributes, interfaces, codegen) |
| Serialization Handling | Manual (must define JsonSerializerContext for complex) |
Automatic via generated code |
| NativeAOT / Trimming | Extra steps to preserve reflection data | Designed for AOT; minimal extra configuration |
| Grouping Multiple Methods | Possible, but less structured | Interface-based approach naturally groups multiple methods as a reusable plugin |
| Use Cases | Small or short-lived projects, quick PoCs | Enterprise solutions with complex needs requiring maintainability and strong typing |
Please add tests and documentation for any new features.
This project is available under [MIT] License. Refer to the LICENSE file for more details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.6.6 | 1,028 | 4/20/2026 |
| 3.6.5 | 64 | 4/18/2026 |
| 3.6.4 | 345 | 3/26/2026 |
| 3.6.3 | 501 | 1/23/2026 |
| 3.6.2 | 111 | 1/15/2026 |
| 3.6.1 | 230 | 12/28/2025 |
| 3.5.0 | 138 | 12/26/2025 |
| 3.4.1 | 17,028 | 11/8/2025 |
| 3.4.0 | 1,256 | 10/21/2025 |
| 3.3.0 | 1,126 | 10/3/2025 |
| 3.2.0 | 1,663 | 9/10/2025 |
| 3.1.1 | 185 | 9/7/2025 |
| 3.0.0 | 1,210 | 7/21/2025 |
| 2.7.0 | 1,473 | 6/2/2025 |
| 2.6.0 | 546 | 5/25/2025 |
| 2.5.10 | 354 | 5/9/2025 |
| 2.5.9.1 | 198 | 5/25/2025 |
| 2.5.9 | 241 | 4/25/2025 |
| 2.5.8.1 | 196 | 5/25/2025 |
| 2.5.8 | 231 | 4/18/2025 |