Skip to content
Tracon

ModelProviderSettings

Namespace Tracon · Assembly Tracon.Abstractions.dll

Helpers that read and validate a provider settings dictionary: the ModelBinding.ProviderSettings of a model binding, and the ProviderSettings of a speech request.

public static class ModelProviderSettings
Inheritance
object ← ModelProviderSettings
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Each provider package knows its own key prefix (anthropic, google, elevenlabs) and carries the list of keys it supports. This type applies that list, so the validation logic is not written again in every new provider package.

An unknown key is not ignored silently. A setting that is ignored makes the user miss the behaviour they expect without seeing why — the same decision as the one taken for ModelBinding.ReasoningEffort.

A refusal names the key, never the value. A value can be text a user wrote or a credential pasted into the wrong field, and the message reaches logs and run records. A value of the wrong type is described by its JSON kind.

Keys are compared case insensitively. When the dictionary is read back from a jsonb column it arrives with the default (ordinal) comparer; the lookup is therefore not left to the comparer of the dictionary itself.

Reads a setting as a boolean value.

public static bool? ReadBoolean(ModelBinding binding, string key)

binding ModelBinding

The model binding.

key string

The full key, for example anthropic.promptCaching.

bool?

null when the setting is not defined.

ArgumentNullException

binding is null.

TraconException

The value is not a boolean value.

Reads a setting as an integer.

public static int? ReadInt32(ModelBinding binding, string key)

binding ModelBinding

The model binding.

key string

The full key, for example anthropic.thinking.budgetTokens.

int?

null when the setting is not defined.

ArgumentNullException

binding is null.

TraconException

The value is not an integer.

Reads a setting as text.

public static string? ReadString(ModelBinding binding, string key)

binding ModelBinding

The model binding.

key string

The full key, for example google.safety.harassment.

string?

null when the setting is not defined or is empty.

ArgumentNullException

binding is null.

TraconException

The value is not text.

Validate(ModelBinding, string, IReadOnlyCollection<string>)

Section titled “ Validate(ModelBinding, string, IReadOnlyCollection<string>)”

Validates that every provider setting in the binding belongs to the given prefix and is supported.

public static void Validate(ModelBinding binding, string providerPrefix, IReadOnlyCollection<string> supportedKeys)

binding ModelBinding

The model binding to check.

providerPrefix string

The key prefix of the provider, for example anthropic.

supportedKeys IReadOnlyCollection<string>

The full keys the provider supports, prefix included, for example anthropic.promptCaching.

ArgumentNullException

One of the parameters is null.

ArgumentException

providerPrefix is empty.

TraconException

The dictionary holds a key that belongs to another provider or that is not recognized. The message lists the supported keys.

Validate(IReadOnlyDictionary<string, JsonElement>, string, IReadOnlyCollection<string>)

Section titled “ Validate(IReadOnlyDictionary<string, JsonElement>, string, IReadOnlyCollection<string>)”

Validates that every key of a provider settings dictionary belongs to the given prefix and is supported.

public static void Validate(IReadOnlyDictionary<string, JsonElement> settings, string providerPrefix, IReadOnlyCollection<string> supportedKeys)

settings IReadOnlyDictionary<string, JsonElement>

The settings to check, for example SpeechRequest.ProviderSettings.

providerPrefix string

The key prefix of the provider, for example elevenlabs.

supportedKeys IReadOnlyCollection<string>

The full keys the provider supports, prefix included, for example elevenlabs.stability. Pass an empty list when the provider supports none.

The same rule as the ModelBinding overload, which runs the same code: keys are compared case-insensitively, a key of another provider is told apart from an unrecognized one, and nothing is ignored silently.

A speech provider that supports one setting checks a request before it calls its service:

ModelProviderSettings.Validate(
request.ProviderSettings,
"contoso",
["contoso.pitch"]);

ArgumentNullException

One of the parameters is null.

ArgumentException

providerPrefix is empty.

TraconException

The dictionary holds a key that belongs to another provider or that is not recognized. The message names those keys and lists the supported ones; it never carries a value.