Skip to main content
All docs
V26.1
  • PromptToReportRequest Class

    A request to generate a report from the specified prompt.

    Namespace: DevExpress.AIIntegration.Reporting.Common.Extensions

    Assembly: DevExpress.AIIntegration.Reporting.Common.v26.1.dll

    Declaration

    [DXBrowsable(true)]
    public class PromptToReportRequest :
        TextRequest

    Remarks

    Describes a prompt-to-report operation, including the user prompt, an optional data source schema, and an optional existing report to update. You can also attach a host to enable interactive generation.

    You can specify the following options:

    PromptToReportRequest.Report
    Specifies an existing report that the generation workflow should update.
    PromptToReportRequest.ReportGenerationHost
    Specifies a host that handles prompt clarifications and progress updates.
    PromptToReportRequest.FixLayoutErrors
    Specifies whether the generation workflow should attempt to fix report layout errors.
    PromptToReportRequest.DataSourceSchema
    Specifies a schema of a report’s data source.

    Example

    The following code sample initializes an AI client, creates a report request, and generates a report based on a user prompt:

    View Example: DevExpress Reports - Generate a Report Based on a User Prompt Within a Console App

    using Reporting.Generation.Console;
    using Azure.AI.OpenAI;
    using System.ClientModel;
    using Microsoft.Extensions.AI;
    using DevExpress.AIIntegration.Reporting.Common.Extensions;
    using DevExpress.AIIntegration;
    using DevExpress.XtraReports.UI;
    
    // 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.2";
    
    // Create an Azure OpenAI client to work with the chat agent.
    IChatClient chatClient = new AzureOpenAIClient(new Uri(endpoint), new ApiKeyCredential(apiKey))
        .GetChatClient(deploymentName)
        .AsIChatClient();
    
    // Register chat client and reporting extensions.
    AIExtensionsContainerDefault container = AIExtensionsContainerConsole.CreateDefaultAIExtensionContainer(chatClient);
    container.RegisterReportingExtensions();
    
    // 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.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine(ex.Message);
        Console.ResetColor();
        Console.WriteLine();
    }
    
    Console.ReadLine();
    

    Inheritance

    Object
    DevExpress.AIIntegration.Extensions.BaseRequest
    TextRequest
    PromptToReportRequest
    See Also