Table of Contents

Class GenerateContentRequestExtensions

Namespace
GenerativeAI
Assembly
GenerativeAI.dll

Provides extension methods for enhancing the functionality of the GenerateContentRequest class.

public static class GenerateContentRequestExtensions
Inheritance
GenerateContentRequestExtensions
Inherited Members

Methods

AddTool(GenerateContentRequest, Tool, ToolConfig?)

Adds a Tool to the GenerateContentRequest with an optional ToolConfig.

public static void AddTool(this GenerateContentRequest request, Tool tool, ToolConfig? config = null)

Parameters

request GenerateContentRequest

The GenerateContentRequest instance to which the Tool will be added.

tool Tool

The Tool to add.

config ToolConfig

Optional ToolConfig for configuring the Tool.

UseEnumMode<T>(GenerateContentRequest, JsonSerializerOptions?)

Configures the GenerateContentRequest to use JSON mode for responses of the specified type T.

public static void UseEnumMode<T>(this GenerateContentRequest request, JsonSerializerOptions? options = null) where T : Enum

Parameters

request GenerateContentRequest

The GenerateContentRequest on which JSON mode will be applied.

options JsonSerializerOptions

Optional JsonSerializerOptions for customizing the serialization process.

Type Parameters

T

The type that defines the response schema for the JSON. Must be a class.

Remarks

For NativeAOT/Trimming JsonSerializerOptions are required, you can ignore it if you have already specified a resolver in

UseJsonMode<T>(GenerateContentRequest, JsonSerializerOptions?)

Configures the GenerateContentRequest to use JSON mode for responses of the specified type T.

public static void UseJsonMode<T>(this GenerateContentRequest request, JsonSerializerOptions? options = null) where T : class

Parameters

request GenerateContentRequest

The GenerateContentRequest on which JSON mode will be applied.

options JsonSerializerOptions

Optional JsonSerializerOptions for customizing the serialization process.

Type Parameters

T

The type that defines the response schema for the JSON. Must be a class.

Remarks

For NativeAOT/Trimming JsonSerializerOptions are required, you can ignore it if you have already specified a resolver in