<style>
table th:first-of-type {
	width: 10%;
}
table th:nth-of-type(2) {
	width: 90%;
}
</style>

# AIClient Element Overview

The `AIClient` element specifies the configuration settings for the GenAI-powered insights functionality of Telerik Reporting. It is used to connect the Reporting engine to a local or remote LLM, as well as configure the behavior of the built-in Reporting AI capabilities.

## Attributes and Elements

**`<AIClient>` element**

| Category       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Attributes     | <ul><li>**friendlyName** - Required string attribute. Specifies the name that corresponds to the type of AI client to be used. The names of the currently supported AI client types are: `MicrosoftExtensionsAzureAIInference`, `MicrosoftExtensionsAzureOpenAI`, `MicrosoftExtensionsOllama`, and `MicrosoftExtensionsOpenAI`.</li><li>**model** - Required string attribute. Specifies the AI model to be used for generating responses. For example, setting the model to "gpt-4o-mini" indicates that the GPT-4o mini model variant is being utilized.</li><li>**endpoint** - Optional string attribute. If set, specifies the URL of the AI service endpoint.</li><li>**credential** - Optional string attribute. If set, specifies the authentication credentials used to access the AI service.</li><li>**requireConsent** - Optional boolean attribute *(true by default)*. Determines whether users must explicitly consent to the use of AI services before the AI report insights features can be utilized within the application.</li><li>**allowRAG** - Optional boolean attribute *(true by default)*. Allows the Retrieval-Augmented Generation (RAG). The *ragSettings* will be respected only when *allowRAG* is *true*.</li><li>**allowCustomPrompts** - Optional boolean attribute *(true by default)*. Determines whether users are allowed to freely communicate with the AI model. If set to false, custom queries are forbidden and only the predefined prompts can be used.</li></ul> |
| Child Elements | <ul><li>**predefinedPrompts** - Optional element. Defines a list of predefined prompts that the AI client can use.</li><li>**ragSettings** - Optional element. Configures the Retrieval-Augmented Generation (RAG) options.</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| Parent Element | **Telerik.Reporting** - Configures all settings that the Telerik Reporting Engine uses.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

**`<predefinedPrompts>` element**

| Category       | Description                                                                                    |
| -------------- | ---------------------------------------------------------------------------------------------- |
| Attributes     | None                                                                                           |
| Child Elements | <ul><li>**add** - Optional element. Adds a prompt to the list of predefined prompts.</li></ul> |
| Parent Element | **AIClient**                                                                                   |

**`<add>` element**

| Category       | Description                                    |
| -------------- | ---------------------------------------------- |
| Attributes     | **text** - The text of a predefined AI prompt. |
| Child Elements | None                                           |
| Parent Element | **predefinedPrompts**                          |

**`<ragSettings>` element**

| Category       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Attributes     | <ul><li>**tokenizationEncoding** - Optional string attribute. If set, specifies the tokenization encoding used for Retrieval-Augmented Generation (RAG). By default, the encoding is determined automatically.</li><li>**modelMaxInputTokenLimit** - Optional integer attribute. If set, specifies the maximum number of input tokens allowed by the RAG model. The default value is 15000.</li><li>**maxNumberOfEmbeddingsSent** - Optional integer attribute. If set, specifies the maximum number of embeddings that can be sent in a single RAG request. The default value is 15.</li><li>**maxTokenSizeOfSingleEmbedding** - Optional integer attribute. If set, specifies the maximum token size allowed for a single embedding in RAG. A value of 0 means there is no limit. The default value is 0.</li><li>**splitTables** - Optional boolean attribute *(true by default)*. Indicates whether tables should be split during Retrieval-Augmented Generation (RAG) processing. When the splitting is allowed, only the relevant table cells will be taken into account, significantly reducing the number of tokens</li></ul> |
| Parent Element | **AIClient**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

> important The `ragSettings` element is valid only in .NET and .NET Standard. It is not supported in the .NET Framework.

> The *ragSettings* will be respected only when *allowRAG* is *true*

## Example

The following code example demonstrates how to configure the Reporting engine with an Azure OpenAI client that uses the GPT-4o mini model variant. In addition, the AI functionality is limited to a few predefined prompts that enable it to summarize and translate the report.

```XML
﻿<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<configSections>
		<section name="Telerik.Reporting"
		         type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting"
		         allowLocation="true"
		         allowDefinition="Everywhere"/>
	</configSections>
	<Telerik.Reporting>
		<AIClient friendlyName="MicrosoftExtensionsAzureOpenAI"
		          model="gpt-4o-mini"
		          endpoint="https://ai-explorations.openai.azure.com/"
		          credential="..."
		          requireConsent="true"
		          allowCustomPrompts="false">
			<predefinedPrompts>
				<add text="Generate an executive summary of this report."/>
				<add text="Translate the document into German."/>
			</predefinedPrompts>
		</AIClient>
	</Telerik.Reporting>
</configuration>
```

```JSON
"telerikReporting": {
    "AIClient": {
        "friendlyName": "MicrosoftExtensionsAzureOpenAI",
        "model": "gpt-4o-mini",
        "endpoint": "https://ai-explorations.openai.azure.com/",
        "credential": "...",
        "requireConsent": true,
        "allowCustomPrompts": false,
        "allowRAG": true,
        "predefinedPrompts": [
            {
                "text": "Generate an executive summary of this report."
            },
            {
                "text": "Translate the document into German."
            }
        ],
        "ragSettings": {
            "tokenizationEncoding": "Set Encoding Name Here",
            "modelMaxInputTokenLimit": 15000,
            "maxNumberOfEmbeddingsSent": 15,
            "maxTokenSizeOfSingleEmbedding": 0,
            "splitTables": true
        }
    }
}
```

> When adding the `Telerik.Reporting` section manually, do not forget to register it in `configSections` element of the configuration file. Failing to do so will result in a [ConfigurationErrorsException](https://learn.microsoft.com/en-us/dotnet/api/system.configuration.configurationerrorsexception?view=dotnet-plat-ext-7.0) with the following text: *Configuration system failed to initialize*.
