Skip to content
Rasmus Wulff Jensen edited this page Dec 26, 2025 · 3 revisions

NuGet README

Features

  • AgentFactory (OpenAIAgentFactory)
  • AIToolsFactory integration (tools in AgentOptions.Tools)
  • EmbeddingFactory (OpenAIEmbeddingFactory)
  • OpenAI reasoning controls and ClientType (ChatClient or ResponsesApi)

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

Connection options

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

Dependency injection

builder.Services.AddOpenAIAgentFactory("<apiKey>");
builder.Services.AddOpenAIAgentFactory(new OpenAIConnection
{
    ApiKey = "<apiKey>",
    NetworkTimeout = TimeSpan.FromMinutes(5)
});

builder.Services.AddOpenAIEmbeddingFactory("<apiKey>");

Notes

Clone this wiki locally