# AI prompts (legacy)

> Bring the assistance of generative AI to your team with the Uniform AI hub.

Source: https://docs.uniform.app/docs/guides/ai/ai-prompts

> **Legacy feature:**
>
> AI prompts is a legacy feature that will continue working for existing projects but is not recommended for new implementations.
>
> For a more flexible and powerful approach, use [Scout](https://docs.uniform.app/docs/guides/ai/scout) for AI-assisted composition building, [AI guidance](https://docs.uniform.app/docs/guides/ai/ai-guidance) to define context for your components and content types, and [AI quick edits](https://docs.uniform.app/docs/guides/ai/ai-quick-edits) for rapid content updates.
>
> AI prompts are likely to be deprecated in the future.

Uniform AI prompts allow you to connect AI integrations to your projects, configure custom large language models, and create prompt templates for specific parameters, fields, or components. This lets you enable generative AI in a way that is adapted to your project’s structure and needs.

Setting up and managing AI prompts in Uniform involves a few high-level steps—such as connecting AI integrations and configuring prompt templates—that are typically performed by developers or experience architects. These steps include:

- [Manage AI integrations](#manage-ai-integrations) to connect your project to an AI service.
- [Manage prompts](#manage-prompts) to create and configure prompt templates.
- [CLI serialization](https://docs.uniform.app/docs/guides/cli/commands/canvas#prompts) to export and import prompts for backup and reuse in other projects.

> **No AI credits required:**
>
> AI prompts do not consume Uniform [AI credits](https://docs.uniform.app/docs/guides/ai/ai-credits). Instead, you register your own API key for the selected AI service (Claude, OpenAI, or Writer), and usage is billed directly through that provider.

## Add AI integrations

AI prompts require that you install one or more AI integrations from the AI category in the integrations page. For each integration, you will usually need to provide an API key and select which model to use.

- [Claude](https://docs.uniform.app/docs/integrations/generative-ai/claude) - Use Claude models for generation content for entries and compositions.
- [OpenAI](https://docs.uniform.app/docs/integrations/generative-ai/openai) - Generate textual content for entries and compositions.
- [Writer](https://docs.uniform.app/docs/integrations/generative-ai/writer) - An alternate source for generating text.

Adding an AI integration is the same as adding any other integration to your Uniform project.

1. Navigate to **Settings > Integrations**. In the "Browse Integrations" section select the **AI** category.
2. Choose one or more of the available integrations, and click **Add to project**.

   ![The available AI integrations.](https://docs.uniform.app/images/guides/composition/ai/add-ai-integration.png)

### Configure Claude

When you select the Claude integration, you will need to provide the API key from your Claude account to complete the connection.

![Enter your credentials to complete the integration.](https://docs.uniform.app/images/guides/composition/ai/configure-claude-integration.png)

> **Want more information?:**
>
> See the [documentation](https://docs.uniform.app/docs/integrations/generative-ai/claude) for this integration.

### Configure OpenAI

When you select the OpenAI integration, you will need to provide your organization, and API key from your account to complete the connection.

![Enter your credentials to complete the integration.](https://docs.uniform.app/images/guides/composition/ai/add-openai-integration.png)

> **Want more information?:**
>
> See the [documentation](https://docs.uniform.app/docs/integrations/generative-ai/openai) for this integration.

### Configure Writer

When you select the Writer integration, you will need to provide your organization, team, and API key from your account to complete the connection.

![Enter your credentials to complete the integration.](https://docs.uniform.app/images/guides/composition/ai/add-writerai-integration.png)

> **Want more information?:**
>
> See the [documentation](https://docs.uniform.app/docs/integrations/generative-ai/writer) for this integration.

## Manage prompts

Once an AI integration has been added to your project, you can manage prompts under **Settings > Prompts**.

Prompts contain the instructions you give a large language model to generate an intended output. Team administrators, or whoever is responsible for setting up components and content types for composition authors can set up the prompts for authors to use when generating content. This requires the `Manage Component Library` [permission](https://docs.uniform.app/docs/guides/roles-and-permissions). These prompts will be available to authors of entries or compositions.

### Create a prompt

To create a prompt:

- Navigate to **Settings > Prompts** within your project.
- Click the **Add prompt** button.
- Select which AI service you want to create a prompt for and click **Add**.
- Enter the following values for the prompt:

  | Field | Description |
  | --- | --- |
  | Prompt name | Enter the name by which you want to identify the prompt on the management page. |
  | Enabled | Once a prompt is enabled it's available in Canvas for use in creating compositions and entities. |
  | Current value | The current value input box mimics the parameter or field value and fills in the current value variable. Only shown if the prompt text contains `Current value` variable. Once a prompt and (if applicable) variables are entered and a response is generated, the output is entered in this field. |
  | Current locale | If your project has more than one configured locale, you can use this variable in the prompt text. Only shown if the prompt text contains `Current locale` variable. |
  | Generate (button) | This button activates the process of generating a response to the prompt. |
  | Prompt text | Instructions sent to the generative AI. These instructions can include **variables**. |

### Variables

Clicking **add variable** opens a drawer in which you can configure a variable to include as part of the prompt. These variables could be product names or any other indicators that could be of use to your composition authors. Multiple variables can be made available for addition into the prompt. The system will expect a value for every variable in the prompt to be added before generating a response.

There are some variables provided by Uniform and available to insertion into prompts:

- **Current Value**: This is populated from the current parameter value.
- **Current Locale**: This is populated from the [currently active locale](https://docs.uniform.app/docs/guides/composition/localization). Only available if your project has more any configured locales
- **Properties list**: Available only for [Multiple text parameters](#generate-multiple-parameters). It will be populated with the list of all text parameters/fields labels in JSON format.
- **Properties current values**: Available only for [Multiple text parameters](#generate-multiple-parameters). It will be populated with the list of all text parameters/fields labels and their values in JSON format.
- **Audience**: Any [audience](https://docs.uniform.app/docs/guides/classification/audiences) configured within your project will be available for insertion into a prompt.

You can add a reference to another parameter/field by creating a custom variable with name starting from `parameter:` and following with **Public ID** of the parameter/field you'd like to reference. For example, `parameter:eyebrowText`. You can specify Display Name for this variable to keep it more user-friendly

![Adding a variable to a prompt.](https://docs.uniform.app/images/guides/composition/ai/add-parameter-reference-variable.png)

You will see Current locale and Parameter Reference variables in the playground only if they are used in the prompt text.

![Prompt editor view with both current locale and parameter reference variables.](https://docs.uniform.app/images/guides/composition/ai/prompt-with-parameter-reference-vars.png)

### Context and availability

When you create a prompt you can configure it to appear on either text or assets parameter/fields. These should be used as expected:

- Text parameters and fields expect text.
- Asset parameters and fields expect binary files.

There is a third option **Multiple text parameters** that allows to consume and generate all text parameters/fields of the composition/entry at once.

### Other options

On the prompt management page, you can access additional management options through opening the menu under . From this menu you can:

- Duplicate the prompt for easy creation of new prompts.
- Disable the prompt to prevent it from being accessed from within compositions and entries.
- Delete the prompt.

![The options available for managing prompts.](https://docs.uniform.app/images/guides/composition/ai/manage-prompts.png)

### Built-in prompts

Each AI integration comes with preconfigured prompts ready for use in compositions or entries.

> **About build-in prompts:**
>
> For more information about built-in prompts, see the [documentation page](https://docs.uniform.app/docs/integrations/generative-ai) for the AI integration.

> **Note:**
>
> Built-in prompts can't be edited so that Uniform can actively manage and update prompts based on customer feedback. You can replace built-in prompts with custom ones by duplicating and disabling the original ones.

## Use generative AI

Now that you have installed the integration and configured your prompts, teams can start generating content in their compositions and entries.

All text and asset [parameters](https://docs.uniform.app/docs/guides/models/components/parameters) and [fields](https://docs.uniform.app/docs/guides/models/content-types/fields) will have a new AI icon in authoring views.

![The AI icon that has been added to a text field.](https://docs.uniform.app/images/guides/composition/ai/ai-icon-on-text-field.png)

### Generate text

Clicking the AI icon on a text field will open a drawer in which any text already entered is shown, along with any available prompts.

![Available prompts for generating text.](https://docs.uniform.app/images/guides/composition/ai/open-ai-to-generate-text.png)

Once you select a prompt you will be able to:

- See the current contents of the parameter or field (if any)
- Enter prompt variables (if applicable)
- Generate a result

From the generated result you can:

- Edit variables (if applicable) and regenerate
- Regenerate to get a new response to the prompt.
- Edit what was returned.
- Accept what was generated. The text will then be entered into the field or parameter.
- Cancel the action.

![An example of working with a prompt from a parameter or field.](https://docs.uniform.app/images/guides/composition/ai/work-with-prompt.png)

### Generate an image

Clicking the AI icon on an asset parameter or field will open a drawer in which any image already entered is shown, along with any available prompts.

![Available prompts for generating images.](https://docs.uniform.app/images/guides/composition/ai/open-ai-to-generate-image.png)

Once you select a prompt you will be able to:

- See the current contents of the parameter or field (if any)
- Enter prompt variables (if applicable)
- Generate a result

From the generated result you can:

- Edit variables (if applicable) and regenerate.
- Regenerate to get a new response to the prompt.
- Select an image.
- Open a full size preview in the modal window.
- Accept what was generated. The image will then be entered into the field or parameter.
- Cancel the action.

![An example of working with a prompt from a parameter or field.](https://docs.uniform.app/images/guides/composition/ai/work-with-prompt-image.png)

### Generate multiple parameters

Clicking the AI icon on a component parameters header "Parameters" or entry fields header "Fields" will open a drawer in which you will see JSON representation of all text parameters (other types are coming later).

![Available prompts for generating multiple parameters.](https://docs.uniform.app/images/guides/composition/ai/work-with-prompt-multi-text.png)

Once you select a prompt you will be able to:

- See the current contents of the parameter in JSON format. Because it is how AI will see it as well.
- Enter prompt variables (if applicable)
- Generate a result

From the generated result you can:

- Edit variables (if applicable) and regenerate.
- Regenerate to get a new response to the prompt.
- Edit what was returned, but be aware that it should be valid JSON in the end. This UI is a subject for changes in the future.
- Accept what was generated. The text will then be entered into the field or parameter.
- Cancel the action.

![Result of multiple text parameters generation.](https://docs.uniform.app/images/guides/composition/ai/work-with-prompt-multi-text-results.png)
