OpenAIProviderExtensions
AgentPrism.OpenAI.dllExtensions that add the OpenAI provider to the AgentPrism chain.
public static class OpenAIProviderExtensionsInheritance
Section titled “Inheritance”object ← OpenAIProviderExtensions
Inherited Members
Section titled “Inherited Members”object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Methods
Section titled “Methods”UseOpenAI(IAgentPrismBuilder, string, Action<OpenAIProviderOptions>?)
Section titled “ UseOpenAI(IAgentPrismBuilder, string, Action<OpenAIProviderOptions>?)”Adds the OpenAI provider with the given API key.
public static IAgentPrismBuilder UseOpenAI(this IAgentPrismBuilder builder, string apiKey, Action<OpenAIProviderOptions>? configure = null)Parameters
Section titled “Parameters”builder IAgentPrismBuilder
The AgentPrism chain.
apiKey string
The OpenAI API key.
configure Action<OpenAIProviderOptions>?
An extra options callback.
Returns
Section titled “Returns”The same chain, for chaining.
Remarks
Section titled “Remarks”The key is passed in by the caller; AgentPrism never reads
IConfiguration on its own, and the key is never written to the
database.
builder.AddAgentPrism() .UseOpenAI(builder.Configuration["OpenAI:ApiKey"]!);Exceptions
Section titled “Exceptions”builder is null.
apiKey is empty.
UseOpenAI(IAgentPrismBuilder, IConfiguration)
Section titled “ UseOpenAI(IAgentPrismBuilder, IConfiguration)”Adds the OpenAI provider with options read from the
AgentPrism:Providers:OpenAI section.
public static IAgentPrismBuilder UseOpenAI(this IAgentPrismBuilder builder, IConfiguration configurationSection)Parameters
Section titled “Parameters”builder IAgentPrismBuilder
The AgentPrism chain.
configurationSection IConfiguration
The section the options are read from. Usually
configuration.GetSection(OpenAIProviderOptions.SectionName).
Returns
Section titled “Returns”The same chain, for chaining.
Exceptions
Section titled “Exceptions”Any parameter is null.
UseOpenAI(IAgentPrismBuilder, Action<OpenAIProviderOptions>)
Section titled “ UseOpenAI(IAgentPrismBuilder, Action<OpenAIProviderOptions>)”Adds the OpenAI provider with options set in code.
public static IAgentPrismBuilder UseOpenAI(this IAgentPrismBuilder builder, Action<OpenAIProviderOptions> configure)Parameters
Section titled “Parameters”builder IAgentPrismBuilder
The AgentPrism chain.
configure Action<OpenAIProviderOptions>
The options callback.
Returns
Section titled “Returns”The same chain, for chaining.
Remarks
Section titled “Remarks”This call registers two providers: OpenAIProviderNames.ChatCompletions and OpenAIProviderNames.Responses. The agent definition picks the one it uses through ModelBinding.Provider.
Registration goes through AddModelProvider(...); no existing service is
replaced. UsePostgreSql uses Replace because it takes the
place of the existing stores; this call adds a new provider, so it has no
such need.
When it is called more than once, the options are merged; the providers are registered only once.
Exceptions
Section titled “Exceptions”Any parameter is null.