AgentFrameworkToolkit.AzureOpenAI 1.25.0

dotnet add package AgentFrameworkToolkit.AzureOpenAI --version 1.25.0
                    
NuGet\Install-Package AgentFrameworkToolkit.AzureOpenAI -Version 1.25.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AgentFrameworkToolkit.AzureOpenAI" Version="1.25.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AgentFrameworkToolkit.AzureOpenAI" Version="1.25.0" />
                    
Directory.Packages.props
<PackageReference Include="AgentFrameworkToolkit.AzureOpenAI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AgentFrameworkToolkit.AzureOpenAI --version 1.25.0
                    
#r "nuget: AgentFrameworkToolkit.AzureOpenAI, 1.25.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AgentFrameworkToolkit.AzureOpenAI@1.25.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AgentFrameworkToolkit.AzureOpenAI&version=1.25.0
                    
Install as a Cake Addin
#tool nuget:?package=AgentFrameworkToolkit.AzureOpenAI&version=1.25.0
                    
Install as a Cake Tool

Agent Framework Toolkit @ Azure OpenAI

This package is aimed at Azure OpenAI as an LLM Provider. Check out the General README.md for other providers and shared features in Agent Framework Toolkit.

What is Agent Framework Toolkit?

Agent Framework Toolkit is an opinionated C# wrapper on top of the Microsoft Agent Framework that makes various things easier to work with:

FAQ

Q: If I use the Agent Framework Toolkit, does it limit or hinder what I can do with Microsoft Agent Framework?

A: No, everything you can do with Microsoft Agent Framework can still be done with Agent Framework Toolkit. It is just a wrapper that enables options that are hard to use otherwise

Q: What is the release frequency of Agent Framework Toolkit (can I always use the latest Microsoft Agent Framework release)?

A: This NuGet package is released as often (or more) than the Microsoft Agent Framework. At a minimum, it will be bumped to the latest Microsoft Agent Framework Release within a day of official release. It follows the same versioning scheme as AF, so the same or higher version number will always be compatible with the latest release.

Q: Why are the agents not AIAgent / ChatClientAgents? Are they compatible with the rest of the Microsoft Agent Framework?

A: The specialized agents in Agent Framework Toolkit are all 100% compatible with AF as they simply inherit from AIAgent

Getting Started

  1. Install the 'AgentFrameworkToolkit.AzureOpenAI' NuGet Package (dotnet add package AgentFrameworkToolkit.AzureOpenAI)
  2. Get your Azure OpenAI API Key
  3. Create an AzureOpenAIAgentFactory instance (Namespace: AgentFrameworkToolkit.AzureOpenAI)
  4. Use instance to create your AzureOpenAIAgent (which is a regular Microsoft Agent Framework AIAgent behind the scenes)

Minimal Code Example

//Create your AgentFactory
AzureOpenAIAgentFactory agentFactory = new AzureOpenAIAgentFactory("<Endpoint>", "<API Key>");

//Create your Agent
AzureOpenAIAgent agent = agentFactory.CreateAgent("gpt-5");
AgentResponse response = await agent.RunAsync("Hello World");
Console.WriteLine(response);

Normal Code Example (API KEY)

//Create your AgentFactory
AzureOpenAIAgentFactory agentFactory = new AzureOpenAIAgentFactory("<Endpoint>", "<API Key>");

//Create your Agent
AzureOpenAIAgent agent = agentFactory.CreateAgent(new AgentOptions //Use AgentOptions overload to access more options
{
    Model = "gpt-5",
    ReasoningEffort = OpenAIReasoningEffort.Low, //Set reasoning effort
    Instructions = "You are a nice AI", //The System Prompt
    Tools = [], //Add your tools here
});

AgentResponse response = await agent.RunAsync("Hello World");
Console.WriteLine(response);

Normal Code Example (RBAC)

//Create your AgentFactory
AzureOpenAIAgentFactory agentFactory = new AzureOpenAIAgentFactory(new AzureOpenAIConnection
{
    Endpoint = "<Endpoint>",
    Credentials = new AzureCliCredential() //Or similar
});

//Create your Agent
AzureOpenAIAgent agent = agentFactory.CreateAgent(new AgentOptions //Use AgentOptions overload to access more options
{
    Model = "gpt-5",
    ReasoningEffort = OpenAIReasoningEffort.Low, //Set reasoning effort
    Instructions = "You are a nice AI", //The System Prompt
    Tools = [], //Add your tools here
});

AgentResponse response = await agent.RunAsync("Hello World");
Console.WriteLine(response);

Full Code example with ALL options

//Create your AgentFactory (using a connection object for more options)
AzureOpenAIAgentFactory agentFactory = new AzureOpenAIAgentFactory(new AzureOpenAIConnection
{
    Endpoint = "<endpoint>",
    ApiKey = "<apiKey>",
    NetworkTimeout = TimeSpan.FromMinutes(5), //Set call timeout
    Credentials = null, //Set RBAC Credentials
    DefaultClientType = ClientType.ResponsesApi, //Set default Client Type for each agent (ChatClient or ResponsesAPI)
    AutoCorrectFoundryEndpoint = true, //Autocorrect Foundry project URLs to the Azure OpenAI endpoint
    AdditionalOpenAIClientOptions = options =>
    {
        //Set additional properties if needed
    }
});

//Create your Agent
AzureOpenAIAgent agent = agentFactory.CreateAgent(new AgentOptions
{
    //Mandatory
    Model = "gpt-5", //Model to use
            
    //Optional (Common)
    ClientType = ClientType.ChatClient, //Choose ClientType (ChatClient or Responses API)
    Name = "MyAgent", //Agent Name
    Temperature = 0, //The Temperature of the LLM Call (1 = Normal; 0 = Less creativity) [ONLY NON-REASONING MODELS]
    ReasoningEffort = OpenAIReasoningEffort.Low, //Set Reasoning Effort [ONLY REASONING MODELS]
    ReasoningSummaryVerbosity = OpenAIReasoningSummaryVerbosity.Detailed, //Only used in Responses API [ONLY REASONING MODELS]
    Instructions = "You are a nice AI", //The System Prompt for the Agent to Follow
    Tools = [], //Add your tools for Tool Calling here
    ToolCallingMiddleware = async (callingAgent, context, next, token) => //Tool Calling Middleware to Inspect, change, and cancel tool-calling
    {
        AIFunctionArguments arguments = context.Arguments; //Details on the tool-call that is about to happen
        return await next(context, token);
    },
    OpenTelemetryMiddleware = new OpenTelemetryMiddleware(source: "MyOpenTelemetrySource", telemetryAgent => telemetryAgent.EnableSensitiveData = true), //Configure OpenTelemetry Middleware

    //Optional (Rarely used)
    MaxOutputTokens = 2000, //Max allow token
    Id = "1234", //Set the ID of Agent (else a random GUID is assigned as ID)
    Description = "My Description", //Description of the Agent (not used by the LLM)
    LoggingMiddleware = new LoggingMiddleware( /* Configure custom logging */),
    Services = null, //Setup Tool Calling Service Injection (See https://youtu.be/EGs-Myf5MB4 for more details)
    LoggerFactory = null, //Setup logger Factory (Alternative to Middleware)
    ChatHistoryProvider = new MyChatMessageStore(), //Set a custom message store
    AIContextProviders = [new MyAIContextProvider()], //Set custom AI context providers
    AdditionalChatClientAgentOptions = options =>
    {
        //Option to set even more options if not covered by AgentFrameworkToolkit
    },
    RawToolCallDetails = Console.WriteLine, //Raw Tool calling Middleware (if you just wish to log what tools are being called. ToolCallingMiddleware is a more advanced version of this)
    RawHttpCallDetails = details => //Intercept the raw HTTP Call to the LLM (great for advanced debugging sessions)
    {
        Console.WriteLine(details.RequestUrl);
        Console.WriteLine(details.RequestData);
        Console.WriteLine(details.ResponseData);
    },
    ClientFactory = client =>
    {
        //Interact with the underlying Client-factory
        return client;
    }
});

AgentResponse response = await agent.RunAsync("Hello World");
Console.WriteLine(response);

Batch Runner

AzureOpenAIBatchRunner batchRunner = new("<endpoint>", "<apiKey>");

ChatBatchRun run = await batchRunner.RunChatBatchAsync(
    new ChatBatchOptions
    {
        Model = "<deployment-name>"
    },
    [
        ChatBatchRequest.Create("Summarize this text.")
    ]);

Note: Batch runner APIs are marked experimental with AFT999. In Azure OpenAI, Model is your deployment name.

Microsoft decision models

AzureOpenAIDecisionFactory implements the shared IDecisionFactory contract used by OpenAI and Jev. Supply a Foundry resource endpoint, authentication, and the deployment name of your Microsoft decision model. The deployment name is required and has no default.

using AgentFrameworkToolkit.AzureOpenAI;
using AgentFrameworkToolkit.Decisions;

IDecisionFactory factory = new AzureOpenAIDecisionFactory(
    "https://YOUR_RESOURCE.services.ai.azure.com", apiKey, "Decision-1");

bool urgent = await factory.IsTrueAsync(new ProbabilityRequest
{
    Input = "My account payment has failed twice today. I need help today.",
    Question = "Does the customer need urgent help?",
    Threshold = 0.7
});

Use ChooseAsync<TEnum>, ProbabilityAsync, and ScoreAsync<TEnum> for individual questions, or CreateDecisionAsync<T> with the shared question attributes for multiple questions and token usage. The same request and result types work across decision providers. Choice and score results retain the API's confidence and full probability distribution. For runtime-defined questions, call the non-generic CreateDecisionAsync overload with DynamicDecisionRequest. It accepts a list of ChoiceQuestion, ScoreQuestion, and ProbabilityQuestion objects. The response exposes case-insensitive GetChoice(id), GetScore(id), and GetProbability(id) accessors directly, alongside model and token usage. See the shared usage example and the Azure sandbox sample. Score results include the API's level descriptions. Refused, missing, or invalid answers throw rather than returning a partial result.

The factory calls /providers/microsoft/v1/systemone with model set to the deployment name, state set to the request's Input, and keyed noul, choice, or score questions. It uses AzureOpenAIConnection for API-key or RBAC authentication, endpoint correction, network timeout, and AdditionalOpenAIClientOptions transport configuration. The connection settings are retained at construction; later connection changes do not reconfigure the factory.

using Azure.Identity;

AzureOpenAIConnection connection = new(
    "https://YOUR_RESOURCE.services.ai.azure.com", new AzureCliCredential())
{
    NetworkTimeout = TimeSpan.FromSeconds(60)
};
AzureOpenAIDecisionFactory factory = new(connection, "Decision-1");

services.AddAzureOpenAIDecisionFactory(connection, "Decision-1");
// Also available: endpoint + API key, or endpoint + TokenCredential.

DI registers the concrete factory and IDecisionFactory as the same singleton. When registering multiple decision providers, resolve their concrete factories; the last registration supplies IDecisionFactory. All operations accept cancellation tokens. Set RawHttpCallDetails on a request to inspect request and response bodies. Total token usage is calculated from input and output counts.

Microsoft-Decision-1 is text-only. Image requests and SafetyIdentifier currently throw NotSupportedException; the common contract remains available to every provider.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on AgentFrameworkToolkit.AzureOpenAI:

Repository Stars
rwjdk/agent-framework-samples
Samples demonstrating the Microsoft Agent Framework in C#
Version Downloads Last Updated
1.25.0 51 10/14/2026
1.24.2 79 10/10/2026
1.24.1 70 10/9/2026
1.24.0 95 10/7/2026
1.23.3 78 10/7/2026
1.23.2 107 10/1/2026
1.23.1 101 9/30/2026
1.23.0 92 9/29/2026
1.22.2 99 9/27/2026
1.22.1 98 9/27/2026
1.22.0 133 9/18/2026
1.21.0 127 9/12/2026
1.20.0 538 8/31/2026
1.19.0 163 8/22/2026
1.18.0 226 8/18/2026
1.17.0 222 8/5/2026
1.16.1 106 8/3/2026
1.16.0 786 7/30/2026
1.15.0 295 7/23/2026
1.14.0 2,305 7/21/2026
Loading failed