OpenAIProviderOptionsValidator
AgentPrism.OpenAI.dllValidates OpenAIProviderOptions while the application starts.
public sealed class OpenAIProviderOptionsValidator : IValidateOptions<OpenAIProviderOptions>Inheritance
Section titled “Inheritance”object ← OpenAIProviderOptionsValidator
Implements
Section titled “Implements”IValidateOptions<OpenAIProviderOptions>
Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”The validation is written by hand; ValidateDataAnnotations relies on
reflection and produces IL2026. AgentPrism.OpenAI must stay AOT
compatible.
The failure messages never contain the API key. Validation messages go to the log and to the startup exception; leaking the key there exposes it.
This validator checks both the unnamed (default) options instance of
UseOpenAI and the named instances of UseOpenAICompatible. The
name parameter of OpenAIProviderOptionsValidator.Validate tells
the two apart: on the unnamed instance (name is empty) the API key is required,
because the official OpenAI service does not work without a key. On a named instance
(a compatible provider) the API key is optional (local servers do not
ask for one) but OpenAIProviderOptions.Endpoint is required — if it were
left empty, the request would silently go to the official OpenAI address.
Constructors
Section titled “Constructors”OpenAIProviderOptionsValidator()
Section titled “ OpenAIProviderOptionsValidator()”public OpenAIProviderOptionsValidator()Methods
Section titled “Methods”Validate(string?, OpenAIProviderOptions)
Section titled “ Validate(string?, OpenAIProviderOptions)”public ValidateOptionsResult Validate(string? name, OpenAIProviderOptions options)Parameters
Section titled “Parameters”name string?
options OpenAIProviderOptions