# AzureOpenAIProviderOptions

> 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.azureopenaiprovideroptions/
> Summary: AzureOpenAIProviderOptions: Tracon's Azure OpenAI provider options.

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

Tracon's Azure OpenAI provider options.

```csharp
public sealed class AzureOpenAIProviderOptions
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.azureopenaiprovideroptions/">AzureOpenAIProviderOptions</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.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>

## Remarks

This type is deliberately a `class`, not a `record`: the
`ToString` a `record` generates writes every property, and a
single log line would expose the API key.

Validation is done by hand inside [Tracon.AzureOpenAIProviderOptionsValidator](/api/tracon/);
`DataAnnotations` relies on reflection and breaks AOT compatibility.

## Constructors

### <a id="Tracon_AzureOpenAIProviderOptions__ctor"></a> AzureOpenAIProviderOptions\(\)

```csharp
public AzureOpenAIProviderOptions()
```

## Fields

### <a id="Tracon_AzureOpenAIProviderOptions_SectionName"></a> SectionName

The full path of the configuration section options are read from.

```csharp
public const string SectionName = "Tracon:Providers:AzureOpenAI"
```

#### Field Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

## Properties

### <a id="Tracon_AzureOpenAIProviderOptions_ApiKey"></a> ApiKey

The Azure OpenAI resource's API key.

```csharp
public string? ApiKey { get; set; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

#### Remarks

**This value is a secret and is not written to a file.** Use
`dotnet user-secrets`, an environment variable, or a secret manager.

When [AzureOpenAIProviderOptions.CredentialFactory](/api/tracon.azureopenaiprovideroptions/#Tracon_AzureOpenAIProviderOptions_CredentialFactory) is given, this field is
**not used**. At least one of the two must be filled in.

### <a id="Tracon_AzureOpenAIProviderOptions_Audience"></a> Audience

The token scope (audience) requested with the Entra credential.
The Azure public cloud is used when [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

```csharp
public string? Audience { get; set; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

#### Remarks

Affects only the [AzureOpenAIProviderOptions.CredentialFactory](/api/tracon.azureopenaiprovideroptions/#Tracon_AzureOpenAIProviderOptions_CredentialFactory) path; it is not used on
the API key path. Sovereign clouds (Azure Government, Azure China)
require a different scope.

Public cloud value: `https://cognitiveservices.azure.com/.default`.
Azure Government: `https://cognitiveservices.azure.us/.default`.

### <a id="Tracon_AzureOpenAIProviderOptions_CredentialFactory"></a> CredentialFactory

The factory that produces a Microsoft Entra credential. When given, this
is used instead of the API key.

```csharp
public Func<TokenCredential>? CredentialFactory { get; set; }
```

#### Property Value

 [Func](https://learn.microsoft.com/dotnet/api/system.func\-1)<[TokenCredential](https://learn.microsoft.com/dotnet/api/azure.core.tokencredential)\>?

#### Remarks

**The factory deliberately comes from the consumer.** The
`DefaultAzureCredential` type needed for a managed credential lives
in the `Azure.Identity` package; that package is not small and pulls
in the `Microsoft.Identity.Client` chain too. `Tracon.Azure`
does not take it as a dependency; it only binds to the `Azure.Core`
abstraction and leaves the credential choice to the consumer.

```csharp
// In the consumer's project: <PackageReference Include="Azure.Identity" />
var options = new AzureOpenAIProviderOptions
{
    CredentialFactory = static () => new DefaultAzureCredential(),
};
```

The factory is called **once** while the client is built.
The returned [TokenCredential](https://learn.microsoft.com/dotnet/api/azure.core.tokencredential) manages token renewal itself.

### <a id="Tracon_AzureOpenAIProviderOptions_DefaultDeployment"></a> DefaultDeployment

The **deployment** name used when [ModelBinding.Model](/api/tracon.modelbinding/#Tracon_ModelBinding_Model)
is left empty.

```csharp
public string? DefaultDeployment { get; set; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

#### Remarks

What Azure calls is not a model name, it is a **deployment
name**. The same model can be deployed under different names, and
the person who sets up the resource chooses the deployment name. A
binding's [ModelBinding.Model](/api/tracon.modelbinding/#Tracon_ModelBinding_Model) is therefore a deployment name
too, and the model catalog lists deployments, not models.

### <a id="Tracon_AzureOpenAIProviderOptions_Endpoint"></a> Endpoint

The Azure OpenAI resource's address. Example:
`https://my-resource.openai.azure.com/`.

```csharp
public Uri? Endpoint { get; set; }
```

#### Property Value

 Uri?

#### Remarks

Required; Azure has no single global address, each resource has its own.
The address is not a secret, but it exposes an organization's topology;
it is **not shown** in error messages or health-check detail.

### <a id="Tracon_AzureOpenAIProviderOptions_Models"></a> Models

The model catalog shown to the UI. Each entry's `Name` field is the
**deployment name**.

```csharp
public IList<ModelDescriptor> Models { get; }
```

#### Property Value

 [IList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist\-1)<[ModelDescriptor](/api/tracon.modeldescriptor/)\>

#### Remarks

Tracon carries no built-in model list; the catalog comes entirely
from here. This list is *not a validation list*: a deployment name
absent from it can still be used.

### <a id="Tracon_AzureOpenAIProviderOptions_Timeout"></a> Timeout

The upper time limit for a single request. The library default is used when [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

```csharp
public TimeSpan? Timeout { get; set; }
```

#### Property Value

 [TimeSpan](https://learn.microsoft.com/dotnet/api/system.timespan)?

#### Remarks

Must be from one millisecond to about 24.8 days ([Int32.MaxValue](https://learn.microsoft.com/dotnet/api/system.int32) milliseconds) when set; any other value fails at startup.
