Table of Contents

Class ServiceCollectionExtension

Namespace
GenerativeAI.Web
Assembly
GenerativeAI.Web.dll

Extension methods for configuring GenerativeAI services in dependency injection.

public static class ServiceCollectionExtension
Inheritance
ServiceCollectionExtension
Inherited Members

Methods

AddGenerativeAI(IServiceCollection)

Adds the Google Generative AI features to the IServiceCollection.

public static IServiceCollection AddGenerativeAI(this IServiceCollection services)

Parameters

services IServiceCollection

The IServiceCollection to add the services to.

Returns

IServiceCollection

The updated IServiceCollection for chaining additional calls.

AddGenerativeAI(IServiceCollection, GenerativeAIOptions)

Adds the Google Generative AI features to the IServiceCollection using the specified options.

public static IServiceCollection AddGenerativeAI(this IServiceCollection services, GenerativeAIOptions options)

Parameters

services IServiceCollection

The IServiceCollection to add the services to.

options GenerativeAIOptions

The configuration options for the Google Generative AI services.

Returns

IServiceCollection

The updated IServiceCollection for chaining additional calls.

AddGenerativeAI(IServiceCollection, IConfiguration)

Adds Google Generative AI features to the IServiceCollection.

public static IServiceCollection AddGenerativeAI(this IServiceCollection services, IConfiguration namedConfigurationSection)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

namedConfigurationSection IConfiguration

The IConfiguration section with service options.

Returns

IServiceCollection

The IServiceCollection so that additional calls can be chained.

AddGenerativeAI(IServiceCollection, Action<GenerativeAIOptions>)

Adds the Google Generative AI features to the IServiceCollection with optional configuration.

public static IServiceCollection AddGenerativeAI(this IServiceCollection services, Action<GenerativeAIOptions> setupAction)

Parameters

services IServiceCollection

The IServiceCollection to add the services to.

setupAction Action<GenerativeAIOptions>

An optional action to configure the GenerativeAIOptions.

Returns

IServiceCollection

The updated IServiceCollection for chaining additional calls.

AddGenerativeAI(IServiceCollection, string)

Adds the Google Generative AI features to the IServiceCollection.

public static IServiceCollection AddGenerativeAI(this IServiceCollection services, string configSectionPath)

Parameters

services IServiceCollection

The IServiceCollection to add the services to.

configSectionPath string

The configuration section path containing Generative AI options.

Returns

IServiceCollection

The updated IServiceCollection for chaining additional calls.

ConfigureGenerativeAI(IServiceCollection, Action<GenerativeAIOptions>)

Configures GenerativeAI options for the service collection.

public static void ConfigureGenerativeAI(this IServiceCollection services, Action<GenerativeAIOptions> setupAction)

Parameters

services IServiceCollection

The service collection to configure.

setupAction Action<GenerativeAIOptions>

The action to configure GenerativeAI options.

WithAdc(IServiceCollection)

Configures the Google ADC (Application Default Credentials) authentication for Generative AI services.

public static void WithAdc(this IServiceCollection services)

Parameters

services IServiceCollection

The IServiceCollection to configure the authentication for.

WithOAuth(IServiceCollection, string)

Configures the IServiceCollection to use Google OAuth authentication for Generative AI services.

public static void WithOAuth(this IServiceCollection services, string clientSecretFilePath)

Parameters

services IServiceCollection

The IServiceCollection to configure.

clientSecretFilePath string

The file path to the client secret JSON file used for Google OAuth authentication.

WithServiceAccount(IServiceCollection, string)

Configures Google Service Account authentication for Generative AI features in the IServiceCollection.

public static void WithServiceAccount(this IServiceCollection services, string jsonFilePath)

Parameters

services IServiceCollection

The IServiceCollection to add the authentication configuration to.

jsonFilePath string

The file path to the JSON credential file for Google Service Account authentication.

WithServiceAccount(IServiceCollection, string, string, string)

Configures Google Service Account authentication for the Generative AI services.

public static void WithServiceAccount(this IServiceCollection services, string serviceAccountEmail, string certificateFilePath, string passPhrase)

Parameters

services IServiceCollection

The IServiceCollection to configure the authentication for.

serviceAccountEmail string

The email address associated with the Google Service Account.

certificateFilePath string

The file path to the service account's certificate.

passPhrase string

The passphrase for the certificate file.