Skip to content
Rasmus Wulff Jensen edited this page Oct 10, 2026 · 6 revisions

NuGet README

Features

  • AgentFactory (OpenAIAgentFactory)
  • AIToolsFactory integration (tools in AgentOptions.Tools)
  • EmbeddingFactory (OpenAIEmbeddingFactory)
  • BatchRunner (OpenAIBatchRunner)
  • DecisionFactory (OpenAIDecisionFactory)
  • OpenAI reasoning controls and ClientType (ChatClient or ResponsesApi)
  • StoredOutputEnabled for the OpenAI store setting
  • ServiceTier for OpenAI service tier selection

Package

dotnet add package AgentFrameworkToolkit.OpenAI

Quick start

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);

Embeddings

OpenAIEmbeddingFactory embeddingFactory = new("<apiKey>");
IEmbeddingGenerator<string, Embedding<float>> generator =
    embeddingFactory.GetEmbeddingGenerator("text-embedding-3-small");
Embedding<float> embedding = await generator.GenerateAsync("Hello");

Decisions

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.

Connection options

  • ApiKey (required)
  • Endpoint (optional, use for OpenAI-compatible providers)
  • NetworkTimeout
  • DefaultClientType
  • AdditionalOpenAIClientOptions

OpenAI-specific agent options

  • ReasoningEffort
  • ReasoningSummaryVerbosity (Responses API)
  • StoredOutputEnabled (maps to OpenAI's store setting)
  • ServiceTier (OpenAI direct only)
  • ClientType (ChatClient or ResponsesApi)

Dependency injection

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);

Notes

Clone this wiki locally