Access Models API with Apex
Access Models API with REST
LWC & Flow Examples
Rate Limits
Model API Names
Generation Feedback
Language & Locales
Data Masking
Toxicity Scoring
AI Models
Prompt Builder
Prompt Template Batch Processing
The Models API can receive text requests that combine data from multiple sources and in potentially different languages. However, not specifying the correct set of languages and locales limits the effectiveness of critical features, such as Data Masking, Toxicity Scoring, and Feedback. To address this issue, you can specify a set of localization parameters in the payload to provide an accurate list of locales or languages included in the prompt, and to generate a response in the desired language.
To learn more, see Einstein Trust Layer Region and Language Support.
To provide multi-language or multi-locale support, specify a localization payload in your request for Generations, Chat Generations, Embeddings. The locale field can contain the ISO language code or a combination of the ISO language code and the ISO country code (language_COUNTRY).
1{
2 "localization": {
3 "defaultLocale": "en_US",
4 "inputLocales": [
5 {
6 "locale": "en_US",
7 "probability": 0.6
8 },
9 {
10 "locale": "es_ES",
11 "probability": 0.4
12 }
13 ],
14 "expectedLocales": ["en_US"]
15 }
16}| Parameter | Type | Required? | Description |
|---|---|---|---|
localization | object | Optional | Parent object containing all localization information. If not specified, we assume en_US (US English). |
defaultLocale | string | Required if localization specified | The default locale. This value determines the region of the prompt for services that require the region, such as data masking. defaultLocale is a fallback value when the provided values for inputLocales or expectedLocales are unsupported for a particular operation. |
inputLocales | array of objects | Optional | The list of language codes or locales found in the prompt’s text. Each item must contain a locale string (with the language or the locale) and an optional probability value (from 0 to 1). The probability is an estimate of how frequently you expect that language to appear in the input. |
expectedLocales | array of strings | Optional | The list of language codes or locales that you want the LLM to use when generating the text. |
defaultLocale value.inputLocales.