---
schema_version: "1"
id: 78b90452b43b081572bb5d91537291985b9091dd6c027b4c933d03247034fc11
title: Data Masking with Models API
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/genai/agentforce/guides/models/models-api/models-api-data-masking.md
canonical_url: https://developer.salesforce.com/docs/ai/agentforce/guide/models-api-data-masking.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: b53b9d90275ebcda2f278a851d6ef625857e6b351b93426c3e41582d4a773492
products:
  - Agentforce Developer Guide
  - Agentforce and Einstein Generative AI
---
# Data Masking with Models API

The Einstein Trust Layer identifies and masks selected personally identifiable information (PII) and payment card industry (PCI) data in the prompts before sending them to the large language model (LLM). Data masking prevents your sensitive data from exposure to the LLM and keeps your sensitive CRM data safely stored inside Salesforce.

## Prerequisites

To ensure that sensitive data is masked, verify that your desired language and locale is supported, and then follow the admin instructions for setting up data masking. See [Einstein Trust Layer Region and Language Support](https://help.salesforce.com/s/articleView?id=ai.generative_ai_trust_lang_region.htm) and [Large Language Model Data Masking](https://help.salesforce.com/s/articleView?id=ai.generative_ai_mask_data.htm) in _Salesforce Help_.

After you verify that your locale is supported and that data masking is turned on, specify the correct locale in your API request. See [Specify Languages and Locales with Models API](https://developer.salesforce.com/docs/ai/agentforce/guide/models-api-languages-and-locales.md).

## How It Works

Data masking involves replacing each value that’s detected with placeholder text based on what it represents. Then, the LLM can maintain the context of the prompt to generate a relevant response. After the LLM returns a response, the Einstein Trust Layer demasks the data that was originally masked. The response that you see has the actual data. You can track data masking and view the masked data by using the audit trail. Audit trail is stored in Data 360.

There’s no programmatic way to handle masked data from the Models API.

**note:** Although our detection models have shown to be effective during internal testing, it’s important to note that no model can guarantee 100% accuracy. In addition, cross-region and multi-country use cases can affect the ability to detect specific data patterns. With trust as our priority, we’re dedicated to the ongoing evaluation and refinement of our models.

## Context Window

Although some of the [supported models](https://developer.salesforce.com/docs/ai/agentforce/supported-models.md#model-criteria) have extended context windows, all models are currently limited to a context size of 65,536 tokens when data masking is turned on in the Einstein Trust Layer. To turn off data masking and use the full context window, see [Set Up Einstein Trust Layer](https://help.salesforce.com/s/articleView?id=ai.generative_ai_trust_setup.htm) in Salesforce Help.

## See Also

- _Salesforce Help_: [Einstein Trust Layer Region and Language Support](https://help.salesforce.com/s/articleView?id=ai.generative_ai_trust_lang_region.htm)
- _Salesforce Help_: [Large Language Model Data Masking](https://help.salesforce.com/s/articleView?id=ai.generative_ai_mask_data.htm)
