This example integrates multi-agent report generation for a .NET 8 console application using Azure OpenAI.
The generated report is saved to the generatedReport.repx file.
- .NET 8 SDK
- Azure OpenAI
- The following NuGet packages should be installed in your project:
To implement report generation in your application, you must:
-
Create an
IChatClientinstance for your AI provider:// Retrieve the Azure OpenAI endpoint, key, and model from user environment variables. string endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT", EnvironmentVariableTarget.User) ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set."); string apiKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY", EnvironmentVariableTarget.User) ?? throw new InvalidOperationException("AZURE_OPENAI_API_KEY is not set."); string deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT", EnvironmentVariableTarget.User) ?? "gpt-5-mini"; // Create an Azure OpenAI client to work with the chat agent. IChatClient chatClient = new AzureOpenAIClient(new Uri(endpoint), new ApiKeyCredential(apiKey)) .GetChatClient(deploymentName) .AsIChatClient();
For additional information, refer to the following help topic: AI-powered Extensions — Register AI Clients.
-
Initialize an AI extensions container to register the AI client and reporting extension:
using DevExpress.AIIntegration.Reporting.Common.Extensions; using DevExpress.AIIntegration; // AIExtensionsContainerDefault container = AIExtensionsContainerConsole.CreateDefaultAIExtensionContainer(chatClient); container.RegisterReportingExtensions();
-
Create a class that implements
IAIReportGenerationHostto handle clarification questions and to show progress/notifications:Implement and supply a host for interactive workflows (ConsoleAIReportGenerationHost.cs).
namespace Reporting.Generation.Console { public class ConsoleAIReportGenerationHost : IAIReportGenerationHost { private string lastStatus = string.Empty; public Task<PromptClarificationAnswer> ClarifyPromptAsync(PromptClarificationQuestion request) { // Render the request in your UI (request.Text and request.Choices). // Return PromptClarificationAnswer.FromValue(selectedChoice). // Return PromptClarificationAnswer.Canceled() if the user cancels the operation. return Task.FromResult(PromptClarificationAnswer.Canceled()); } public void NotifyAsync(string status, string reasoning) { bool isNewStatus = lastStatus != status; lastStatus = status; // Surface progress to users (console, logger, status bar, web socket, etc.). // Update the status when isNewStatus is true; otherwise refresh the reasoning only. } } }
-
Generate the report from a prompt.
In the Program.cs file, create a
PromptToReportRequestinstance with the user prompt, assign the host, and specify additional settings. CallAIReportingIntegration.GeneratePromptToReportAsyncto obtain anXtraReportinstance.using Reporting.Generation.Console; using DevExpress.AIIntegration.Reporting.Common.Extensions; using DevExpress.XtraReports.UI; // ... // Ask the user for a report description in natural language. Console.WriteLine("Specify a prompt to generate the report:"); string prompt = Console.ReadLine(); try { // Create a host to handle clarification questions and progress notifications. ConsoleAIReportGenerationHost host = new ConsoleAIReportGenerationHost(); // Build a generation request from the user prompt. PromptToReportRequest generationRequest = new PromptToReportRequest(userPrompt: prompt, dataSourceSchema: null, report: null) { ReportGenerationHost = host, FixLayoutErrors = true }; // Generate a report layout and save it to a REPX file. XtraReport report = await container.GeneratePromptToReportAsync(generationRequest, default); report.SaveLayoutToXml("generatedReport.repx"); } catch (Exception ex) { Console.WriteLine($"Report generation failed: {ex.Message}"); }
- PromptToReportRequest Class
- IAIReportGenerationHost Interface
- PromptClarificationQuestion Class
- PromptClarificationAnswer Class
(you will be redirected to DevExpress.com to submit your response)

