New to Telerik UI for ASP.NET CoreStart a free 30-day trial

Integration with Microsoft.Extensions.AI

The AIPrompt component incorporates the Microsoft.Extensions.AI package to simplify your AI model integration, provide flexibility and allows you to easily use and test various AI providers.

Other components will support similar integration in future versions of UI for ASP.NET Core.

Integration

To integrate the Microsoft.Extensions.AI library with your AIPrompt component, register an IChatClient service and configure it according to the model you are using. The AIPrompt is designed to automatically use the registered IChatClient.

Microsoft.Extensions.AI provides a simple integration with various models where the configuration slightly differs depending on the model. The example below shows usage of Azure OpenAI and you may explore some other examples with different models in this post.

Program.cs
    // Add services to the container.

    // Register the Azure OpenAI client.
    builder.Services.AddSingleton(new AzureOpenAIClient(
        new Uri("YOUR_AZURE_OPENAI_ENDPOINT"),
        new AzureKeyCredential("YOUR_AZURE_OPENAI_CREDENTIAL")
    ));

    // Register the Chat client with the specified model.
    builder.Services.AddChatClient(services => 
        services.GetRequiredService<AzureOpenAIClient>()
            .AsChatClient("gpt-4o-mini")
    );

For the complete IChatClient example, refer to the kendo-ui-demos-service GitHub repository.

See Also

In this article
IntegrationSee Also
Not finding the help you need?
Contact Support