# GoogleProviderExtensions

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.googleproviderextensions/
> Summary: GoogleProviderExtensions: Extensions that add the Google Gemini provider to the Tracon chain.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Google.dll</code></div>

Extensions that add the Google Gemini provider to the Tracon chain.

```csharp
public static class GoogleProviderExtensions
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.googleproviderextensions/">GoogleProviderExtensions</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Methods

### <a id="Tracon_GoogleProviderExtensions_UseGoogle_Tracon_ITraconBuilder_System_String_System_Action_Tracon_GoogleProviderOptions__"></a> UseGoogle\(ITraconBuilder, string, Action<GoogleProviderOptions\>?\)

Adds the Google provider by giving an API key.

```csharp
public static ITraconBuilder UseGoogle(this ITraconBuilder builder, string apiKey, Action<GoogleProviderOptions>? configure = null)
```

#### Parameters

`builder` [ITraconBuilder](/api/tracon.itraconbuilder/)

Tracon chain.

`apiKey` [string](https://learn.microsoft.com/dotnet/api/system.string)

Gemini Developer API key.

`configure` [Action](https://learn.microsoft.com/dotnet/api/system.action\-1)<[GoogleProviderOptions](/api/tracon.googleprovideroptions/)\>?

Additional settings changer.

#### Returns

 [ITraconBuilder](/api/tracon.itraconbuilder/)

The chain, for further configuration.

#### Remarks

```csharp
builder.AddTracon()
       .UseGoogle(builder.Configuration["Google:ApiKey"]!);
```

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

`builder` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

 [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception)

`apiKey` is empty.

### <a id="Tracon_GoogleProviderExtensions_UseGoogle_Tracon_ITraconBuilder_Microsoft_Extensions_Configuration_IConfiguration_"></a> UseGoogle\(ITraconBuilder, IConfiguration\)

Adds the Google provider, reading settings from the
`Tracon:Providers:Google` section.

```csharp
public static ITraconBuilder UseGoogle(this ITraconBuilder builder, IConfiguration configurationSection)
```

#### Parameters

`builder` [ITraconBuilder](/api/tracon.itraconbuilder/)

Tracon chain.

`configurationSection` [IConfiguration](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.iconfiguration)

Section to read settings from. Typically
`configuration.GetSection(GoogleProviderOptions.SectionName)`.

#### Returns

 [ITraconBuilder](/api/tracon.itraconbuilder/)

The chain, for further configuration.

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

One of the parameters is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

### <a id="Tracon_GoogleProviderExtensions_UseGoogle_Tracon_ITraconBuilder_System_Action_Tracon_GoogleProviderOptions__"></a> UseGoogle\(ITraconBuilder, Action<GoogleProviderOptions\>\)

Adds the Google provider by giving settings in code.

```csharp
public static ITraconBuilder UseGoogle(this ITraconBuilder builder, Action<GoogleProviderOptions> configure)
```

#### Parameters

`builder` [ITraconBuilder](/api/tracon.itraconbuilder/)

Tracon chain.

`configure` [Action](https://learn.microsoft.com/dotnet/api/system.action\-1)<[GoogleProviderOptions](/api/tracon.googleprovideroptions/)\>

Settings changer.

#### Returns

 [ITraconBuilder](/api/tracon.itraconbuilder/)

The chain, for further configuration.

#### Remarks

This call registers a single provider: [GoogleProviderNames.Google](/api/tracon.googleprovidernames/#Tracon_GoogleProviderNames_Google).

Registration uses `AddModelProvider(...)`; no existing service is
*replaced*. When called more than once, settings are
merged; the provider is registered only once.

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

One of the parameters is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).
