Skip to content

Connections

Rasmus Wulff Jensen edited this page Jan 27, 2026 · 7 revisions

Caution

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

What are connections?

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

Advanced/Provider Specific options

In more advanced cases, you might need additional options 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);

All Options on connections

Here is a list of all Properties on the various connection objects

Property Description & Notes Supported Providers
ApiKey The API-Key to authenticate against the LLM
- GitHub uses AccessToken instead
- AzureOpenAI offer an RBAC alternative
- AmazonBedrock uses a bearer token applied via AWS_BEARER_TOKEN_BEDROCK (if not already defined)
Most
AccessToken GitHub Models access token (fine-grained PAT with Models access) GitHub
Region AWS region for Amazon Bedrock Runtime (RegionEndpoint) AmazonBedrock
NetworkTimeout Timeout Settings (if your LLM Calls take longer than the default HTTP Timeout) All
DefaultClientType Control if Agents created should use ChatClient or Responses API protocol if not specified specifically by the Agent
- Default is ChatClient
AzureOpenAI, OpenAI, OpenRouter, XAI
Endpoint Control the Endpoint the LLM Talk to
- Mandatory for AzureOpenAI; for the rest, this is optional
- Can be used in OpenAI to implement 3rd party OpenAI providers
AzureOpenAI, OpenAI, OpenRouter, XAI, Anthropic
AdditionalOpenAIClientOptions Option to set additional OpenAIClientOptions
- Used for not out of the box scenarios for this toolkit
OpenAI, OpenRouter, XAI
Credentials (TokenCredential) Azure Role Based Access Control
- Use Standard Azure RBAC like example AzureCliCredential
AzureOpenAI
AutoCorrectFoundryEndpoint Autocorrect Foundry project URLs like https://[name].services.ai.azure.com/api/projects/[project] to https://[name].services.ai.azure.com (Default = true) AzureOpenAI
AdditionalAzureOpenAIClientOptions Option to set additional AzureOpenAIClientOptions
- Used for not out of the box scenarios for this toolkit
AzureOpenAI
AdditionalAzureAIInferenceClientOptions Option to set additional AzureAIInferenceClientOptions
- Used for not out of the box scenarios for this toolkit
GitHub
VertexAI If set, uses Vertex AI APIs instead of Gemini API Google
Credential (ICredential) Vertex-only credentials Google
Project Vertex-only project id Google
Location Vertex-only location Google
HttpOptions Advanced Google HTTP options Google

Clone this wiki locally