Models API Developer Guide (Beta)

This feature is a Beta Service. Customer may opt to try such Beta Service in its sole discretion. Any use of the Beta Service is subject to the applicable Beta Services Terms provided at Agreements and Terms.

The Models API provides Apex classes and REST endpoints that connect your application to large language models (LLMs) from Salesforce partners, including Azure OpenAI and OpenAI. You can use any Salesforce-enabled model that can be configured in Einstein Studio.

For a list of API names and other details about specific models, see Supported Models for Models API.

All calls to the Models API go through the Einstein Trust Layer.

Models API isn't currently supported on scratch orgs.

The capabilities of the Models API are expressed as Apex methods or REST endpoints, depending on which version of the API you choose.

The Models API can generate a message for a chat conversation. The chat capability allows you to prompt the model with a list of messages rather than just one prompt (providing only one message is fine too). Each message in the list represents a part of a conversation history. You must specify a role for each message: one of user, system, or assistant. The role helps the model understand the conversation and know how to respond. After you pass in this information, the API responds with generated text.

An embedding is a mathematical representation of a chunk of data. Sometimes an embedding is called an embedding vector. When you create embeddings for chunks of data, you can then measure how semantically similar one chunk of data is with another. Embeddings are used for many powerful applications, including retrieval-augmented generation (RAG) and search features.

The Models API can generate text from a single prompt instead of a whole chat conversation. The generate text capability is useful for simple, non-conversational tasks and for testing the capabilities of a model.

You can provide feedback on any generated text created by the Models API. You can use this data, which is stored in Data Cloud, to review the quality of the responses and then update your requests or your model configurations. See Einstein Audit and Feedback Data in Salesforce Help.

To learn how to use the Models API to unlock these capabilities, see our Apex and REST access guides. The Apex classes are great for developing solutions directly in your org. You can also use the Apex classes to build out Lightning web components. The REST API can be used from your existing implementation wherever it resides.