Repository navigation
OpenAI
Rasmus Wulff Jensen edited this page Oct 10, 2026
·
6 revisions
- AgentFactory (
OpenAIAgentFactory) - AIToolsFactory integration (tools in
AgentOptions.Tools) - EmbeddingFactory (
OpenAIEmbeddingFactory) - BatchRunner (
OpenAIBatchRunner) - DecisionFactory (
OpenAIDecisionFactory) - OpenAI reasoning controls and
ClientType(ChatClient or ResponsesApi) -
StoredOutputEnabledfor the OpenAIstoresetting -
ServiceTierfor OpenAI service tier selection
dotnet add package AgentFrameworkToolkit.OpenAI
OpenAIAgentFactory agentFactory = new("<apiKey>");
OpenAIAgent agent = agentFactory.CreateAgent(new AgentOptions
{
Model = "gpt-5",
ReasoningEffort = OpenAIReasoningEffort.Low,
Instructions = "You are a nice AI"
});
AgentRunResponse response = await agent.RunAsync("Hello World");
Console.WriteLine(response);OpenAIEmbeddingFactory embeddingFactory = new("<apiKey>");
IEmbeddingGenerator<string, Embedding<float>> generator =
embeddingFactory.GetEmbeddingGenerator("text-embedding-3-small");
Embedding<float> embedding = await generator.GenerateAsync("Hello");using AgentFrameworkToolkit.Decisions;
IDecisionFactory decisionFactory = new OpenAIDecisionFactory(
"<apiKey>", OpenAIChatModels.Gpt6Luna);
bool urgent = await decisionFactory.IsTrueAsync(new ProbabilityRequest
{
Input = "The production website is unavailable.",
Question = "Does this need urgent attention?",
Threshold = 0.7
});OpenAI supports text and inline image decisions. Version 1.24.2 adds runtime-defined
questions using DynamicDecisionRequest and DynamicDecisionImageRequest.
Retrieve full answers directly through GetChoice(id), GetScore(id), and
GetProbability(id) on the non-generic DecisionResponse.
See runtime-defined questions for
the full text example and image questions
for an inline image example. DecisionFactories also covers
typed decisions, scores, probabilities, and shared provider usage.
-
ApiKey(required) -
Endpoint(optional, use for OpenAI-compatible providers) NetworkTimeoutDefaultClientTypeAdditionalOpenAIClientOptions
ReasoningEffort-
ReasoningSummaryVerbosity(Responses API) -
StoredOutputEnabled(maps to OpenAI'sstoresetting) -
ServiceTier(OpenAI direct only) -
ClientType(ChatClient or ResponsesApi)
builder.Services.AddOpenAIAgentFactory("<apiKey>");
builder.Services.AddOpenAIAgentFactory(new OpenAIConnection
{
ApiKey = "<apiKey>",
NetworkTimeout = TimeSpan.FromMinutes(5)
});
builder.Services.AddOpenAIEmbeddingFactory("<apiKey>");
builder.Services.AddOpenAIDecisionFactory("<apiKey>", OpenAIChatModels.Gpt6Luna);- See AgentFactories for shared options and middleware.
- See EmbeddingFactories for more examples.
- See AIToolsFactory for tool creation and MCP support.
- See BatchRunners for OpenAI batch jobs.
- See DecisionFactories for decision API examples.