New to Kendo UI for jQuery? Start a free 30-day trial

Returns a request configuration object that can be sent to AI services for processing natural language prompts. This method generates a standardized request format that includes the user's prompt and column metadata, which AI services can use to generate appropriate Grid commands.

Use this method when implementing custom AI integrations or when you need to send Grid context to an AI service endpoint. The returned object can be serialized to JSON and sent directly to compatible AI services.

Parameters:promptString

The user's natural language prompt describing the desired Grid operation (e.g., "sort by name ascending", "filter rows where age is greater than 30", "highlight all rows from New York").

Returns:Object

A request configuration object with the following structure:

<div id="grid"></div>
<script>
  $("#grid").kendoGrid({
    columns: [
      { field: "name", title: "Name" },
      { field: "age", title: "Age" },
      { field: "city", title: "City" }
    ],
    dataSource: [
      { name: "Jane Doe", age: 30, city: "New York" },
      { name: "John Doe", age: 33, city: "London" },
      { name: "Sam Smith", age: 25, city: "Paris" }
    ],
    sortable: true,
    filterable: true,
    toolbar: [{
      template: '<input id="aiPrompt" class="k-input" placeholder="Ask AI..." style="width: 300px; margin-right: 10px;" />' +
                '<button id="askAI" class="k-button k-button-primary">Apply</button>'
    }]
  });

  var grid = $("#grid").data("kendoGrid");

  $("#askAI").on("click", function() {
    var prompt = $("#aiPrompt").val();

    if (!prompt) {
      return;
    }

    // Get the AI request object with prompt and column metadata
    var aiRequest = grid.getAIRequest(prompt);

    $.ajax({
      url: "https://sitdemos.telerik.com/service/v2/ai/grid/smart-state",
      method: "POST",
      contentType: "application/json",
      data: JSON.stringify(aiRequest),
      success: function(response) {
        // Process the AI response to apply commands to the Grid
        grid.handleAIResponse(response);
        $("#aiPrompt").val("");
      },
      error: function(xhr) {
        console.log("AI service error:", xhr.responseText);
      }
    });
  });
</script>
Not finding the help you need?
Contact Support