# AnthropicProviderExtensions

> 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.anthropicproviderextensions/
> Summary: AnthropicProviderExtensions: Extensions that add the Anthropic (Claude) provider to the Tracon chain.

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

Extensions that add the Anthropic (Claude) provider to the Tracon chain.

```csharp
public static class AnthropicProviderExtensions
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.anthropicproviderextensions/">AnthropicProviderExtensions</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_AnthropicProviderExtensions_UseAnthropic_Tracon_ITraconBuilder_System_String_System_Action_Tracon_AnthropicProviderOptions__"></a> UseAnthropic\(ITraconBuilder, string, Action<AnthropicProviderOptions\>?\)

Adds the Anthropic provider using an API key.

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

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

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

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

#### Returns

 [ITraconBuilder](/api/tracon.itraconbuilder/)

The continuation of the chain.

#### Remarks

```csharp
builder.AddTracon()
       .UseAnthropic(builder.Configuration["Anthropic: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_AnthropicProviderExtensions_UseAnthropic_Tracon_ITraconBuilder_Microsoft_Extensions_Configuration_IConfiguration_"></a> UseAnthropic\(ITraconBuilder, IConfiguration\)

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

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

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

`configurationSection` [IConfiguration](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.iconfiguration)

The section settings are read from. Typically
`configuration.GetSection(AnthropicProviderOptions.SectionName)`.

#### Returns

 [ITraconBuilder](/api/tracon.itraconbuilder/)

The continuation of the chain.

#### 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_AnthropicProviderExtensions_UseAnthropic_Tracon_ITraconBuilder_System_Action_Tracon_AnthropicProviderOptions__"></a> UseAnthropic\(ITraconBuilder, Action<AnthropicProviderOptions\>\)

Adds the Anthropic provider using settings given in code.

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

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

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

#### Returns

 [ITraconBuilder](/api/tracon.itraconbuilder/)

The continuation of the chain.

#### Remarks

This call registers a single provider: [AnthropicProviderNames.Anthropic](/api/tracon.anthropicprovidernames/#Tracon_AnthropicProviderNames_Anthropic).

Registration uses `AddModelProvider(...)`; no existing service is
*replaced*. Calling this more than once merges the
settings; 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).
