Skip to content

Connections

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

All providers of AgentFactories and EmbeddingFactories need credentials to authenticate against the underlying services.

Often, such credentials are a single api-key (or an endpoint + api-key) that can be given to a factory:

//Sample: Creating an OpenAI Agent Factory
OpenAIAgentFactory agentFactory = new OpenAIAgentFactory("<api-key>");

Caution

Remember to always store secrets like api-key in UserSecrets, Environment Variables, Key Vaults or similar; NEVER directly in the code!

Advanced and Provider Specific Settings

In more advanced cases however, you might need additional settings for the connection, such as timeouts, endpoints, in which case you make a provider-specific Connection object:

//Sample: Creating an OpenAI Connection
OpenAIConnection connection = new OpenAIConnection
{
    ApiKey = "<api-key>",
    NetworkTimeout = TimeSpan.FromMinutes(5), //Set call timeout
});

//Pass connection to Factory instead of simple api-key
OpenAIAgentFactory agentFactory = new OpenAIAgentFactory(connection);

Options on connections

Property Decription Supported Providers
NetworkTimeout Timeout Settings (if your LLM Calls takes longer that default HTTP Timeout) All but Google
AccessToken GitHub's alternative to api-key GitHub
  • Role Based Acccess Control is needed [Azure-based Connections only]
  • An alternative Endpoint to the default needs to be set [OpenAI-Based Providers]
  • The OpenAI ResponsesAPI needs to be used by default [OpenAI-Based Providers only]

Clone this wiki locally