Skip to main content

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.

Postman Collection

The quickest way to get started with the Models REST API is with our Postman collection.

Endpoints

Generate a response based on a list of messages representing a chat conversation.

Authorizations:
orgJWT
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 EinsteinGPT.

x-client-feature-id
required
string
Example: ai-platform-models-connected-app

This value is reserved for future use. For now, specify ai-platform-models-connected-app.

Request Body schema: application/json;charset=utf-8
required
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

Content type
application/json;charset=utf-8
{
  • "messages": [
    • {
      }
    ],
  • "localization": {
    • "defaultLocale": "en_US",
    • "inputLocales": [
      ],
    • "expectedLocales": [
      ]
    },
  • "tags": { }
}

Response samples

Content type
application/json
{
  • "id": "014DFFD2-04B5-4765-8EA7-507585268CD3",
  • "generationDetails": {
    • "generations": [
      ],
    • "parameters": {
      }
    }
}

Create an embedding vector representing the input text.

Authorizations:
orgJWT
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 EinsteinGPT.

x-client-feature-id
required
string
Example: ai-platform-models-connected-app

This value is reserved for future use. For now, specify ai-platform-models-connected-app.

Request Body schema: application/json;charset=utf-8
required
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

Content type
application/json;charset=utf-8
{
  • "input": [
    • "Every day, once a day, give yourself a present"
    ]
}

Response samples

Content type
application/json

Note: Embedding array truncated to 1 item for brevity.

{
  • "embeddings": [
    • {
      }
    ],
  • "parameters": {
    • "usage": {
      },
    • "model": "text-embedding-ada-002-v2",
    • "object": "list"
    }
}

Generate a response based on the provided prompt.

Authorizations:
orgJWT
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 EinsteinGPT.

x-client-feature-id
required
string
Example: ai-platform-models-connected-app

This value is reserved for future use. For now, specify ai-platform-models-connected-app.

Request Body schema: application/json;charset=utf-8
required
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

Content type
application/json;charset=utf-8
{
  • "prompt": "Invent 3 fun names for donuts",
  • "localization": {
    • "defaultLocale": "en_US",
    • "inputLocales": [
      ],
    • "expectedLocales": [
      ]
    },
  • "tags": { }
}

Response samples

Content type
application/json
{
  • "id": "chatcmpl-8diKGsPooFDwwhbJxmibpUc7437at",
  • "generation": {
    • "id": "4399c4ea-89d4-44ca-ae8d-cf5926b41bc4",
    • "generatedText": "The generated text.",
    • "contentQuality": {
      },
    • "parameters": {
      }
    },
  • "moreGenerations": [
    • {
      }
    ],
  • "prompt": "Invent 3 fun names for donuts",
  • "parameters": {
    • "model": "gpt-3.5-turbo-0125",
    • "object": "chat.completion",
    • "usage": {
      }
    }
}

Submit feedback for generated text.

Authorizations:
orgJWT
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 EinsteinGPT.

x-client-feature-id
required
string
Example: ai-platform-models-connected-app

This value is reserved for future use. For now, specify ai-platform-models-connected-app.

Request Body schema: application/json
required
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 /generations response, or use any other identifier as a string value. The Models API doesn’t do any semantic validation on this field and it’s only meant for you to identify this information in the datastore.

feedback
string or null
Enum: "GOOD" "BAD"

The feedback sentiment. Can be null.

feedbackText
string

The textual representation of the feedback as provided by the user.

source
string

The source of the feedback. For example, human or app.

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

Content type
application/json
{
  • "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

Content type
application/json
{
  • "message": "Feedback received, Thank you!"
}