Models REST API (v1)
Download OpenAPI specification:Download
The Models REST API connects your application to large language models (LLMs) through the Einstein Trust Layer. To get started, see Access Models API with REST.
The quickest way to get started with the Models REST API is with our Postman collection.
- Generate Chat: Generate a response based on a list of messages representing a chat conversation.
- Generate Embeddings: Create an embedding vector representing the input text.
- Generate Text: Generate a response based on the provided prompt.
- Submit Feedback: Submit feedback for generated text.
Generate a response based on a list of messages representing a chat conversation.
Authorizations:
path Parameters
modelName required | string Configured model name. |
header Parameters
Authorization required | string Example: Bearer ••••• Authorization information that contains the JWT. For guidance, see Access Models API with REST. |
x-sfdc-app-context required | string Example: EinsteinGPT This value is reserved for future use. For now, specify |
x-client-feature-id required | string Example: ai-platform-models-connected-app This value is reserved for future use. For now, specify |
Request Body schema: application/json;charset=utf-8required
required | Array of objects (ChatMessageRequest) List of messages to send to the model. These messages should be in chronological order. |
object (Localization) Localization information, which can include the default locale, input locale(s), and expected output locale(s). | |
object or null (Tags) Entries used by the Models API for non-generative purposes and entries used by the client for free-form data. |
Responses
Request samples
- Payload
{- "messages": [
- {
- "role": "user",
- "content": "Can you give me a recipe for cherry pie?"
}
], - "localization": {
- "defaultLocale": "en_US",
- "inputLocales": [
- {
- "locale": "en_US",
- "probability": 0.8
}
], - "expectedLocales": [
- "en_US"
]
}, - "tags": { }
}
Response samples
- 200
- 400
- 401
- 403
- 404
- 423
- 429
- 500
- 503
- default
{- "id": "014DFFD2-04B5-4765-8EA7-507585268CD3",
- "generationDetails": {
- "generations": [
- {
- "id": "string",
- "role": "user",
- "content": "Can you give me a recipe for cherry pie?",
- "timestamp": 1682536893,
- "parameters": {
- "finish_reason": "stop",
- "index": 0,
- "logprobs": null
}, - "contentQuality": {
- "scanToxicity": {
- "isDetected": true,
- "categories": [
- {
- "categoryName": "profanity",
- "score": 0
}
]
}
}
}
], - "parameters": {
- "model": "gpt-3.5-turbo",
- "object": "text_completion",
- "usage": {
- "completion_tokens": 235,
- "prompt_tokens": 91,
- "total_tokens": 326
}
}
}
}
Create an embedding vector representing the input text.
Authorizations:
path Parameters
modelName required | string Configured model name. |
header Parameters
Authorization required | string Example: Bearer ••••• Authorization information that contains the JWT. For guidance, see Access Models API with REST. |
x-sfdc-app-context required | string Example: EinsteinGPT This value is reserved for future use. For now, specify |
x-client-feature-id required | string Example: ai-platform-models-connected-app This value is reserved for future use. For now, specify |
Request Body schema: application/json;charset=utf-8required
input required | Array of strings Input text used for generating an embedding. Data is encoded as an array of strings. |
object (Localization) Localization information, which can include the default locale, input locale(s), and expected output locale(s). | |
object or null (Tags) Entries used by the Models API for non-generative purposes and entries used by the client for free-form data. |
Responses
Request samples
- Payload
{- "input": [
- "Every day, once a day, give yourself a present"
]
}
Response samples
- 200
- 400
- 401
- 403
- 404
- 423
- 429
- 500
- 503
- default
Note: Embedding array truncated to 1 item for brevity.
{- "embeddings": [
- {
- "embedding": [
- 0.0015662104
], - "index": 0
}
], - "parameters": {
- "usage": {
- "prompt_tokens": 11,
- "total_tokens": 11
}, - "model": "text-embedding-ada-002-v2",
- "object": "list"
}
}
Generate a response based on the provided prompt.
Authorizations:
path Parameters
modelName required | string Example: sfdc_ai__DefaultAzureOpenAIGPT35Turbo Configured model name. |
header Parameters
Authorization required | string Example: Bearer ••••• Authorization information that contains the JWT. For guidance, see Access Models API with REST. |
x-sfdc-app-context required | string Example: EinsteinGPT This value is reserved for future use. For now, specify |
x-client-feature-id required | string Example: ai-platform-models-connected-app This value is reserved for future use. For now, specify |
Request Body schema: application/json;charset=utf-8required
prompt required | string The prompt or text to be completed. |
object (Localization) Localization information, which can include the default locale, input locale(s), and expected output locale(s). | |
object or null (Tags) Entries used by the Models API for non-generative purposes and entries used by the client for free-form data. |
Responses
Request samples
- Payload
{- "prompt": "Invent 3 fun names for donuts",
- "localization": {
- "defaultLocale": "en_US",
- "inputLocales": [
- {
- "locale": "en_US",
- "probability": 0.8
}
], - "expectedLocales": [
- "en_US"
]
}, - "tags": { }
}
Response samples
- 200
- 400
- 401
- 403
- 404
- 423
- 429
- 500
- 503
- default
{- "id": "chatcmpl-8diKGsPooFDwwhbJxmibpUc7437at",
- "generation": {
- "id": "4399c4ea-89d4-44ca-ae8d-cf5926b41bc4",
- "generatedText": "The generated text.",
- "contentQuality": {
- "scanToxicity": {
- "isDetected": true,
- "categories": [
- {
- "categoryName": "profanity",
- "score": 0
}
]
}
}, - "parameters": {
- "finish_reason": "stop",
- "index": 0,
- "logprobs": null
}
}, - "moreGenerations": [
- {
- "id": "4399c4ea-89d4-44ca-ae8d-cf5926b41bc4",
- "generatedText": "The generated text.",
- "contentQuality": {
- "scanToxicity": {
- "isDetected": true,
- "categories": [
- {
- "categoryName": "profanity",
- "score": 0
}
]
}
}, - "parameters": {
- "finish_reason": "stop",
- "index": 0,
- "logprobs": null
}
}
], - "prompt": "Invent 3 fun names for donuts",
- "parameters": {
- "model": "gpt-3.5-turbo-0125",
- "object": "chat.completion",
- "usage": {
- "prompt_tokens": 14,
- "completion_tokens": 15,
- "total_tokens": 29
}
}
}
Submit feedback for generated text.
Authorizations:
header Parameters
Authorization required | string Example: Bearer ••••• Authorization information that contains the JWT. For guidance, see Access Models API with REST. |
x-sfdc-app-context required | string Example: EinsteinGPT This value is reserved for future use. For now, specify |
x-client-feature-id required | string Example: ai-platform-models-connected-app This value is reserved for future use. For now, specify |
Request Body schema: application/jsonrequired
id | string A unique ID for the feedback object. |
generationId | string Identifies the target of this feedback data. You can specify the ID of a |
feedback | string or null Enum: "GOOD" "BAD" The feedback sentiment. Can be |
feedbackText | string The textual representation of the feedback as provided by the user. |
source | string The source of the feedback. For example, |
object Dictionary of any app-level feedback and any other free-form parameters. | |
appGenerationId | string App-specific generation ID to support cases where the client has multiple responses in a single generation. |
appGeneration | string App-specific generation text to support cases where the client has multiple responses in a single generation. |
Responses
Request samples
- Payload
{- "id": "d123449d-afed-4abe-9a0e-19c90726d2ea",
- "generationId": "d321449d-afed-4abe-9a0e-19c90726d2ea",
- "feedback": "GOOD",
- "feedbackText": "string",
- "source": "string",
- "appFeedback": { },
- "appGenerationId": "string",
- "appGeneration": "d567849d-afed-4abe-9a0e-19c90726d2ea"
}
Response samples
- 202
- 400
- 401
- 403
- 404
- 423
- 429
- 503
- default
{- "message": "Feedback received, Thank you!"
}