Skip to content

AgentFactories

Rasmus Wulff Jensen edited this page Dec 25, 2025 · 18 revisions

Each of the providers has an AgentFactory with its related name (AnthropicAgentFactory, AzureOpenAIAgentFactory, GitHubAgentFactory, GoogleAgentFactory, MistralAgentFactory, OpenAIAgentFactory, OpenRouterAgentFactory, OpenAIAgentFactory)

Each serves the purpose of creating Agent Definitions for you to use to call the LLMs

You have 2 ways to create an Agent Factory (the sample below shows creating an AnthropicAgentFactory, but all follow the same process)

Option 1. Create a new instance manually (using simplified connection info or a Connection instance

AnthropicAgentFactory agentFactory1 = new AnthropicAgentFactory("<api-key>");

//or

AnthropicAgentFactory agentFactory2 = new AnthropicAgentFactory(new AnthropicConnection
{
   ApiKey = "<api-key>",
   NetworkTimeout = TimeSpan.FromMinutes(5)
});

Option 2. Use Dependency Injection

builder.Services.AddAnthropicAgentFactory("<api-key");

//or

builder.Services.AddAnthropicAgentFactory(new AnthropicConnection
{
    ApiKey = "<api-key>",
    NetworkTimeout = TimeSpan.FromMinutes(5)
});

Clone this wiki locally