RadzenAIChat component that provides a modern chat interface with AI integration and conversation memory.
IComponent
IHandleEvent
IHandleAfterRender
RadzenComponent.SetParametersAsync
RadzenComponent.RaiseContextMenu
RadzenComponent.RaiseMouseEnter
RadzenComponent.AddContextMenu
RadzenComponent.RaiseMouseLeave
RadzenComponent.OnBecameInvisible
RadzenComponent.DefaultCulture
RadzenComponent.IsJSRuntimeAvailable
ComponentBase.OnParametersSet
ComponentBase.StateHasChanged
ComponentBase.ShouldRender
ComponentBase.OnAfterRender
ComponentBase.InvokeAsync
ComponentBase.DispatchExceptionAsync
ComponentBase.RendererInfo
ComponentBase.Assets
ComponentBase.AssignedRenderMode
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
public class RadzenAIChat : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender<RadzenAIChat Title="AI Assistant" Placeholder="Type your message..." @bind-Messages="@chatMessages" SessionId="@sessionId" />RadzenAIChat component that provides a modern chat interface with AI integration and conversation memory.
public RadzenAIChat()Gets or sets the API key for authentication.
public string ApiKey { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the API key for authentication. |
Gets or sets the API key header name.
public string ApiKeyHeader { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the API key header name. |
Gets or sets the text displayed in the assistant avatar.
public string AssistantAvatarText { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the text displayed in the assistant avatar. |
Event callback that is invoked when the chat is cleared.
public EventCallback ChatCleared { get; set; }
| Type | Description |
|---|---|
| EventCallback | Event callback that is invoked when the chat is cleared. |
Gets or sets whether the chat is disabled.
public bool Disabled { get; set; }
| Type | Description |
|---|---|
| bool | Gets or sets whether the chat is disabled. |
Gets or sets the message displayed when there are no messages.
public string EmptyMessage { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the message displayed when there are no messages. |
Gets or sets the empty template shown when there are no messages.
public RenderFragment EmptyTemplate { get; set; }
| Type | Description |
|---|---|
| RenderFragment | Gets or sets the empty template shown when there are no messages. |
Gets or sets the endpoint URL for the AI service.
public string Endpoint { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the endpoint URL for the AI service. |
Specifies additional custom attributes that will be rendered by the input.
public IReadOnlyDictionary<string, object> InputAttributes { get; set; }
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, object> | Specifies additional custom attributes that will be rendered by the input. |
Gets or sets the maximum number of messages to keep in the chat.
public int MaxMessages { get; set; }
| Type | Description |
|---|---|
| int | Gets or sets the maximum number of messages to keep in the chat. |
Gets or sets the max tokens.
public int? MaxTokens { get; set; }
| Type | Description |
|---|---|
| int? | Gets or sets the max tokens. |
Event callback that is invoked when a new message is added.
public EventCallback<ChatMessage> MessageAdded { get; set; }
| Type | Description |
|---|---|
| EventCallback<ChatMessage> | Event callback that is invoked when a new message is added. |
Event callback that is invoked when a message is sent.
public EventCallback<string> MessageSent { get; set; }
| Type | Description |
|---|---|
| EventCallback<string> | Event callback that is invoked when a message is sent. |
Gets or sets the message template.
public RenderFragment<ChatMessage> MessageTemplate { get; set; }
| Type | Description |
|---|---|
| RenderFragment<ChatMessage> | Gets or sets the message template. |
Gets or sets the model name.
public string Model { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the model name. |
Gets or sets the placeholder text for the input field.
public string Placeholder { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the placeholder text for the input field. |
Gets or sets the proxy URL for the AI service.
public string Proxy { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the proxy URL for the AI service. |
Gets or sets whether the input is read-only.
public bool ReadOnly { get; set; }
| Type | Description |
|---|---|
| bool | Gets or sets whether the input is read-only. |
Event callback that is invoked when the AI response is received.
public EventCallback<string> ResponseReceived { get; set; }
| Type | Description |
|---|---|
| EventCallback<string> | Event callback that is invoked when the AI response is received. |
Gets or sets the session ID for maintaining conversation memory. If null, a new session will be created.
public string SessionId { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the session ID for maintaining conversation memory. If null, a new session will be created. |
Event callback that is invoked when a session ID is created or retrieved.
public EventCallback<string> SessionIdChanged { get; set; }
| Type | Description |
|---|---|
| EventCallback<string> | Event callback that is invoked when a session ID is created or retrieved. |
Gets or sets whether to show the clear chat button.
public bool ShowClearButton { get; set; }
| Type | Description |
|---|---|
| bool | Gets or sets whether to show the clear chat button. |
Gets or sets the system prompt.
public string SystemPrompt { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the system prompt. |
Gets or sets the temperature.
public double? Temperature { get; set; }
| Type | Description |
|---|---|
| double? | Gets or sets the temperature. |
Gets or sets the title displayed in the chat header.
public string Title { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the title displayed in the chat header. |
Gets or sets the text displayed in the user avatar.
public string UserAvatarText { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the text displayed in the user avatar. |
Adds a message to the chat.
public ChatMessage AddMessage(string content, bool isUser)
| Type | Name | Description |
|---|---|---|
| string | content | The message content. |
| bool | isUser | Whether the message is from the user. |
| Type | Description |
|---|---|
| ChatMessage | The created message. |
protected override void BuildRenderTree(Rendering.RenderTreeBuilder __builder)
| Type | Name | Description |
|---|---|---|
| Rendering.RenderTreeBuilder | __builder |
Clears all messages from the chat.
public Task ClearChat()
| Type | Description |
|---|---|
| Task |
protected override string GetComponentCssClass()
| Type | Description |
|---|---|
| string |
Gets the current list of messages.
public IReadOnlyList<ChatMessage> GetMessages()
| Type | Description |
|---|---|
| IReadOnlyList<ChatMessage> |
Gets the current session ID.
public string GetSessionId()
| Type | Description |
|---|---|
| string |
Loads conversation history from the AI service session.
public Task LoadConversationHistory()
| Type | Description |
|---|---|
| Task |
protected override Task OnAfterRenderAsync(bool firstRender)
| Type | Name | Description |
|---|---|---|
| bool | firstRender |
| Type | Description |
|---|---|
| Task |
protected override Task OnInitializedAsync()
| Type | Description |
|---|---|
| Task |
protected override Task OnParametersSetAsync()
| Type | Description |
|---|---|
| Task |
Sends a message programmatically.
public Task SendMessage(string content)
| Type | Name | Description |
|---|---|---|
| string | content | The message content to send. |
| Type | Description |
|---|---|
| Task |
Sends a message programmatically.
public Task SendMessage(string content, string model, string systemPrompt, double? temperature, int? maxTokens, string endpoint, string proxy, string apiKey, string apiKeyHeader)
| Type | Name | Description |
|---|---|---|
| string | content | The message content to send. |
| string | model | |
| string | systemPrompt | |
| double? | temperature | |
| int? | maxTokens | |
| string | endpoint | |
| string | proxy | |
| string | apiKey | |
| string | apiKeyHeader |
| Type | Description |
|---|---|
| Task |