-
-
Notifications
You must be signed in to change notification settings - Fork 4
OpenAI
Rasmus Wulff Jensen edited this page Dec 26, 2025
·
3 revisions
- AgentFactory (
OpenAIAgentFactory) - AIToolsFactory integration (tools in
AgentOptions.Tools) - EmbeddingFactory (
OpenAIEmbeddingFactory) - OpenAI reasoning controls and
ClientType(ChatClient or ResponsesApi)
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");-
ApiKey(required) -
Endpoint(optional, use for OpenAI-compatible providers) NetworkTimeoutDefaultClientTypeAdditionalOpenAIClientOptions
builder.Services.AddOpenAIAgentFactory("<apiKey>");
builder.Services.AddOpenAIAgentFactory(new OpenAIConnection
{
ApiKey = "<apiKey>",
NetworkTimeout = TimeSpan.FromMinutes(5)
});
builder.Services.AddOpenAIEmbeddingFactory("<apiKey>");- See AgentFactories for shared options and middleware.
- See EmbeddingFactories for more examples.
- See AIToolsFactory for tool creation and MCP support.