# `AI_GENERATE_TEXT` (Beta)

**Applies to:** ✅ Data 360 SQL ❌ Tableau Hyper API

:::note
`AI_GENERATE_TEXT` is a pilot or beta service that is subject to the Beta Services Terms at [Agreements - Salesforce.com](https://www.salesforce.com/company/legal/) or a written Unified Pilot Agreement if executed by Customer, and applicable terms in the [Product Terms Directory](https://ptd.salesforce.com/). Use of this pilot or beta service is at the Customer's sole discretion.
:::

Calls the Nemotron 3 Nano 30B (Beta) large language model (LLM) in a Data 360 SQL query to generate or summarize text. The function returns generated text for each row of data. To get started with this function in beta, turn on **Beta Generative AI Models**. To find this beta feature: under **Platform Tools** in **Setup**, go to **Einstein**, then to **Einstein Generative AI**, and then to **Einstein Setup**.

## Syntax

```sql
ai_generate_text(<input_prompt>)
```

## Arguments

### Required

- `input_prompt`: The [text](/docs/data/data-cloud-query-guide/references/dc-sql-reference/string.md) prompt sent to the model. This can be a column, a literal, or an expression that composes a prompt from other columns (for example, by using the [string concatenation operator](/docs/data/data-cloud-query-guide/references/dc-sql-reference/concatenation-operator.md)).

## Returns

Returns generated [text](/docs/data/data-cloud-query-guide/references/dc-sql-reference/string.md) for each row according to the input prompt. A language model generates the output, so the same prompt can produce different text on different runs.

## Considerations

- This is a beta function, and its output behavior may change during the beta period.
- When you turn on Beta Generative AI Models, the underlying model (NVIDIA Nemotron 3 Nano 30B on Amazon (Beta)) is enabled by default. If the model isn't available, queries that call this function fail with a "model not available" error. To verify that the model is available, open the **App Launcher**, select **AI Models**, choose **Library (Generative)**, and confirm that NVIDIA Nemotron 3 Nano 30B on Amazon (Beta) appears under **Model Name**. For the models that support generative AI features, see [Supported Models for Generative AI Features](https://help.salesforce.com/s/articleView?id=ai.generative_ai_large_language_model_support.htm\&type=5).
- Requests to the function time out after 30 seconds. To stay within the timeout, reduce the amount of data the query processes. For example, use `ORDER BY` with `LIMIT` to cap the number of rows sent to the model.
- `input_prompt` must be a non-NULL value. Add `NON_NULL` to the `WHERE` clause in your SQL statement to avoid `NULL` value errors.

## Examples

### Generate Text from a Literal Prompt

Generate text from a single prompt.

```sql
SELECT ai_generate_text(input_prompt => 'Write a one-sentence thank-you note to a customer.') AS generated_text
```

Returns the generated text for the prompt.

### Summarize Table Data

Generate a short summary of customer feedback for each row in a table.

```sql
SELECT
  "customerServiceFeedback__c",
  ai_generate_text('Summarize this customer feedback in one sentence: ' || "customerServiceFeedback__c") AS summary
FROM "AutomobileServiceFeedback__dll"
ORDER BY "date__c"
DESC LIMIT 10
```

This example builds the prompt for each row with the [string concatenation operator](/docs/data/data-cloud-query-guide/references/dc-sql-reference/concatenation-operator.md) (`||`). The operator joins the fixed instruction text, `'Summarize this customer feedback in one sentence: '`, to the value in the `customerServiceFeedback__c` column, so each row sends its own feedback text to the model as part of the prompt.

Returns a one-sentence summary of the feedback for each row.

### Create a Unified Customer Profile Brief

Compose a prompt from identity, purchase, and service fields on a unified profile to generate a short brief for sales or service users.

```sql
SELECT
  "Id__c",
  ai_generate_text(
    'Write a two-sentence customer brief from these details. Name: ' || "FirstName__c" || ' ' || "LastName__c" ||
    '. Loyalty tier: ' || "LoyaltyTier__c" ||
    '. Last purchase category: ' || "LastPurchaseCategory__c" ||
    '. Recent service issue: ' || "LastCaseSummary__c"
  ) AS profile_brief
FROM "UnifiedIndividual__dlm"
ORDER BY "LastActivityDate__c" DESC
LIMIT 25
```

This example uses the [string concatenation operator](/docs/data/data-cloud-query-guide/references/dc-sql-reference/concatenation-operator.md) (`||`) to build a prompt from several profile fields, so the model generates a personalized brief for each customer. `ORDER BY` with `LIMIT` keeps the query within the 30-second timeout by capping how many rows are sent to the model.

## Related Documentation

- [AI Functions](/docs/data/data-cloud-query-guide/references/dc-sql-reference/ai-funcs.md)
- [Supported Models for Generative AI Features](https://help.salesforce.com/s/articleView?id=ai.generative_ai_large_language_model_support.htm\&type=5)
- [Generative AI Usage](https://help.salesforce.com/s/articleView?id=ai.generative_ai_usage.htm\&type=5)
