:doc:`CloudTrail <../../cloudtrail>` / Client / generate_query

**************
generate_query
**************



.. py:method:: CloudTrail.Client.generate_query(**kwargs)

  

  Generates a query from a natural language prompt. This operation uses generative artificial intelligence (generative AI) to produce a ready-to-use SQL query from the prompt.

   

  The prompt can be a question or a statement about the event data in your event data store. For example, you can enter prompts like "What are my top errors in the past month?" and “Give me a list of users that used SNS.”

   

  The prompt must be in English. For information about limitations, permissions, and supported Regions, see `Create CloudTrail Lake queries from natural language prompts <https://docs.aws.amazon.com/awscloudtrail/latest/userguide/lake-query-generator.html>`__ in the *CloudTrail* user guide.

   

  .. note::

    

    Do not include any personally identifying, confidential, or sensitive information in your prompts.

     

    This feature uses generative AI large language models (LLMs); we recommend double-checking the LLM response.

    

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/cloudtrail-2013-11-01/GenerateQuery>`_  


  **Request Syntax**
  ::

    response = client.generate_query(
        EventDataStores=[
            'string',
        ],
        Prompt='string'
    )
    
  :type EventDataStores: list
  :param EventDataStores: **[REQUIRED]** 

    The ARN (or ID suffix of the ARN) of the event data store that you want to query. You can only specify one event data store.

    

  
    - *(string) --* 

    

  :type Prompt: string
  :param Prompt: **[REQUIRED]** 

    The prompt that you want to use to generate the query. The prompt must be in English. For example prompts, see `Example prompts <https://docs.aws.amazon.com/awscloudtrail/latest/userguide/lake-query-generator.html#lake-query-generator-examples>`__ in the *CloudTrail* user guide.

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'QueryStatement': 'string',
          'QueryAlias': 'string',
          'EventDataStoreOwnerAccountId': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **QueryStatement** *(string) --* 

        The SQL query statement generated from the prompt.

        
      

      - **QueryAlias** *(string) --* 

        An alias that identifies the prompt. When you run the ``StartQuery`` operation, you can pass in either the ``QueryAlias`` or ``QueryStatement`` parameter.

        
      

      - **EventDataStoreOwnerAccountId** *(string) --* 

        The account ID of the event data store owner.

        
  
  **Exceptions**
  
  *   :py:class:`CloudTrail.Client.exceptions.EventDataStoreARNInvalidException`

  
  *   :py:class:`CloudTrail.Client.exceptions.EventDataStoreNotFoundException`

  
  *   :py:class:`CloudTrail.Client.exceptions.InactiveEventDataStoreException`

  
  *   :py:class:`CloudTrail.Client.exceptions.InvalidParameterException`

  
  *   :py:class:`CloudTrail.Client.exceptions.GenerateResponseException`

  
  *   :py:class:`CloudTrail.Client.exceptions.OperationNotPermittedException`

  
  *   :py:class:`CloudTrail.Client.exceptions.UnsupportedOperationException`

  
  *   :py:class:`CloudTrail.Client.exceptions.NoManagementAccountSLRExistsException`

  