Skip to content

ModelBinding

Namespace AgentPrism · Assembly AgentPrism.Abstractions.dll

Determines the provider and the model an agent runs with. It carries no credentials; the API key is resolved from configuration.

public sealed record ModelBinding : IEquatable<ModelBinding>

objectModelBinding

IEquatable<ModelBinding>

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

public ModelBinding()

Gets the ordered fallback chain tried when the primary provider is unavailable. Empty by default.

public IReadOnlyList<ModelFallback> Fallbacks { get; init; }

IReadOnlyList<ModelFallback>

Empty by default: with no fallback configured, today’s behavior is preserved exactly — a provider failure (for example an open circuit) still throws, and no fallback code path runs.

A fallback link carries only a provider and a model, not a full ModelBinding: ModelBinding.Temperature, ModelBinding.ProviderSettings, and the other fields do not carry over to the fallback call. A fallback model that needs its own settings is a separate configuration concern, not something this chain expresses.

Switching to a fallback is never silent: the run record gets an explicit ModelFallbackUsed event, and cost and model attribution (RunStatistics.ByModel) reflect the model that actually answered, not the primary binding.

Gets the upper output token limit. The provider default is used when it is null.

public int? MaxOutputTokens { get; init; }

int?

Gets the model name, for example gpt-5.4-mini.

public required string Model { get; init; }

string

Gets the provider name, for example openai.

public required string Provider { get; init; }

string

Gets the provider-specific extra settings. A key has the form {provider}.{setting}.

public IReadOnlyDictionary<string, JsonElement> ProviderSettings { get; init; }

IReadOnlyDictionary<string, JsonElement>

The prompt caching of Anthropic or the safety thresholds of Gemini do not fit the fixed fields of this contract. Adding them to the body of ModelBinding would leak one vendor’s concept into AgentPrism.Abstractions. This dictionary keeps the contract clean: each provider reads only its own prefix.

An unknown key is not ignored silently. When a provider sees a key it does not recognize, the build fails and lists the keys it supports. The reason is the same as for ModelBinding.ReasoningEffort: a setting that is ignored silently makes the user miss the behaviour they expect without seeing why.

Keys are compared with StringComparer.OrdinalIgnoreCase. Use the ModelProviderSettings helpers to read them.

"ProviderSettings": {
"anthropic.promptCaching": true,
"anthropic.thinking.budgetTokens": 8000,
"google.safety.harassment": "BLOCK_ONLY_HIGH"
}

Gets the reasoning effort level. Models that support it use the value; the other providers ignore it.

public string? ReasoningEffort { get; init; }

string?

The valid values are the Microsoft.Extensions.AI.ReasoningEffort names: None, Low, Medium, High, ExtraHigh. The comparison is case insensitive. An unrecognized value is rejected while the agent is built, with AgentPrismCompilationException; it is not ignored silently.

Gets the requested output format. When it is null today’s behaviour does not change: no format constraint is sent to the provider.

public AgentResponseFormat? ResponseFormat { get; init; }

AgentResponseFormat?

AgentResponseFormatKind.Text differs from null: null means “say nothing”, Text means “ask for plain text explicitly”. An invalid combination (for example AgentResponseFormatKind.JsonSchema without a schema) is rejected while the agent is built, with AgentPrismCompilationException.

Gets the sampling temperature. The provider default is used when it is null.

public float? Temperature { get; init; }

float?

Gets the nucleus sampling threshold. The provider default is used when it is null.

public float? TopP { get; init; }

float?

public override bool Equals(object? obj)

obj object?

bool

public bool Equals(ModelBinding? other)

other ModelBinding?

bool

public override int GetHashCode()

int

public override string ToString()

string

operator ==(ModelBinding?, ModelBinding?)

Section titled “ operator ==(ModelBinding?, ModelBinding?)”
public static bool operator ==(ModelBinding? left, ModelBinding? right)

left ModelBinding?

right ModelBinding?

bool

operator !=(ModelBinding?, ModelBinding?)

Section titled “ operator !=(ModelBinding?, ModelBinding?)”
public static bool operator !=(ModelBinding? left, ModelBinding? right)

left ModelBinding?

right ModelBinding?

bool