Loading...

The Models API plays a significant role in providing access to and facilitating interaction with large language models (LLMs) from various Salesforce partners such as Anthropic, Google, and OpenAI. It enables applications to leverage these models for various tasks, including text generation and other AI-powered capabilities.

As a user, you can configure any Salesforce-enabled model with Einstein Studio. If you want to customize model hyperparameters, create a custom-configured model in Einstein Studio and later use it with the Models API. 

Key Capabilities To Consider:

  1. Generate Chat
  2. Generate Embeddings
  3. Generate Text
  4. Submit Feedback

Steps to Generate Chat Using Model API

The Models API requires access to Einstein Generative AI on your Salesforce Org. If you don’t have an Org with this feature, you can get an Einstein AI Playground org from Trailhead to experiment or you can get a Developer Edition org with Agentforce and Data Cloud to experiment.

Step 1: Create a Salesforce Connected App

  • Log in to your newly created Salesforce org.
  • Go to the setup Button.
unnamed 24
  • Search for ‘Generative AI’ in the Quick Find box and select ‘Einstein Setup’
blogImg.1
  • After turning on Einstein, search for ‘App Manager’ in the Quick Find box, select ‘App Manager’, and click on ‘New Connected App’.
blogImg.2 1
  • Select “Create a Connected App” from the given two points mentioned below:
  1. Connected apps support plugins other than OAuth 2.0.
  2. ‘Create an External Client App’ supports only OAuth 2.0 plugins.
  •  Fill in the following details:
blogImg.3

Enable ‘OAuth settings’,
Fill ‘Callback URL’

  • Select the mentioned ‘OAuth Scopes’.
blogImg.4
blogImg.5
  • Click on the Save button, then continue.
  • A new Page will open, then click on the ‘Manage’ button.
m
  • Click on ‘Edit Policies’.
blogImg.7
  • Click on ‘Run as’, select the user you want to assign, check the appropriate checkbox, and save.
unnamed 32
  • After saving, you need to open the newly created Connected App from ‘App Manager’. Once the app is open, click on ‘Manage Consumer Details’.
unnamed 33
  • When you click on the ‘Manage Consumer Details’ button, you’ll be prompted to enter a verification code. Once it is done, you’ll be redirected to the Consumer Details Page, where you can find the Key and Secret.
blogImg.10

Step 2: Now go to Auth Providers and click on “New”

blogImg.11
  • Select ‘Provider Type’ as ‘Salesforce/Open id Connect’.
  • Fill in the Name (URL suffix will fill automatically), Consumer key, and consumer secret, and leave the rest. Then click on save.
s
  • Click on ‘Save’, and then copy the Callback URL provided.
unnamed 38
  • Now go back to your created App, and click on edit.
blogImg.14
  • And paste the URL in the Callback URL section and click on save.
blogImg.15

P.S. – You’ll get this message, just click continue. 

unnamed 41

Step 3: Set Up Named Credentials:

Now we have to create a Named Credential in Source ORG (In this example, in our org).

  • First, go to my domain and copy the Current My Domain URL and copy it.
blogImg.17
  • Now, go to the Named Credentials tab and click on the ‘New Legacy’ option.
blogImg.18
  • Fill in the details below (The URL will contain the Current My Domain URL that we copied and add “https://” before that), click on the little search icon before Authentication Provider, and click on save. Once you click on save.
blogImg.19
  • You’ll be redirected to the login page, log in to the target org, and click on Allow.
ss
  • Now that we’ve set up everything in our org, we can test it in Postman.

Step 4: Set Up in Postman

Now that we’ve set up everything in our org, we can have a demo in the Postman.

  • Go to the provided URL: Models API Postman, and create a fork.
blogImg.20
  • Once you’ve created a fork, now it’s time to generate an authentication code.
  • Fill in Variable values after creating your workspace in Postman as mentioned below.

authDomain: Current My Domain URL( in My Domain)

clientId: Consumer Key from Connected App.

clientSecret: Consumer Secret from Connected App.

modelName: You can select any model Name from the given link( Supported Model).

_baseUrl: remain it as it is.

unnamed 49
  • Now, generate an authentication code if you want to test it directly in Postman. Inside ‘Authentication’ Click on the ‘ Get new Access Token’ button,  then ‘Proceed’, and then  ‘Use Token’.
blogImg.23
  • From the above Page inside the ‘Authentication’ tab, copy ‘Access Token URL’ and then paste it into ‘the Token Endpoint URL’ field of ‘Auth. Provider you created above, and enter the ‘Authorize Endpoint URL’ field value as mentioned below.

Authorize Endpoint URL: https://hostname/services/oauth2/authorize

Replace the hostname with My Domain URL(as mentioned in the below image).

blogImg.24
blogImg.25

Step 5: Development Work

  • Now you can go into any of the 4 sections of the Models API, we will explore all 4 options and what they do.

You can use the below chat based on your preference:

1. Generate text (standalone prompt)

In this, you will ask the chatbot only one question, and it will give you the answer based on that. 

blogImg.26

For example, we will ask “Tell me a developer Joke?” (Like why not, we are developers and we deserve a good developer joke)

blogImg.27

2. Generate chat (conversation with context)

In this, you will have a conversation with the chatbot, and the model will consider the previous chat and reply accordingly.

blogImg.28

As you can see, the chatbot has replied accordingly, but this is only 1 message and its reply, so what now? Now we can use the result it gave us and add our message.

blogImg.29

I have added the response from the assistant and gave my following message as well; now it will reply accordingly.

blogImg.30

3. Generate embeddings

An embedding is a numerical representation of a chunk of content. Sometimes an embedding is called an embedding vector. To measure the semantic similarity between two chunks of content, you can use mathematical operations on their embedding vectors, such as cosine similarity, Euclidean distance, or dot product.

blogImg.31

Submit Feedback

This is based on the above text or chat, we can provide feedback if the chat is good or bad.

blogImg.32

We need to fill in the following details. In this example, we will provide the selected field and the ID from the above text.

blogImg.331 2

5.1 Create Apex class and Lightning component which uses the models API:

Now that we know how to use these models, we can create an intuitive UI to display the data.

For that, we need a lightning web component and an apex class.

  • Create Lightning Web Component (LWC). Open your Visual Studio Code and create a project, and in that:
unnamed 62
  • Create Apex Class in a similar way (Apex class name callModelAPIdata and Lwc name chatWindow).
  • Now copy the entire code.
  • LWC
  • CSS
  • JS
  • Apex code

Step 6: The Final Output

Now that we have put all the pieces together, we can finally see what it looks like.

unnamed 63
  • The green bubble represents the message sent to us, while the blue bubble represents the API’s response in a conversation format.
  • I have put this component on the Account record page, but you can put it on any page depending on your preference.

Demo Video

No Data Found.

Related Articles
How to Integrate NikoHealth to Salesforce

Healthcare organizations using NikoHealth often need patient, insurance, order, invoice, and prescription data available inside Salesforce. As data grows, manually updating records across systems becomes difficult and can lead to delays, duplicate work, and data inconsistencies. NikoHealth to Salesforce integration helps solve this challenge by automatically synchronizing data between both platforms. Instead of building custom […]

Read More
Orchestrator vs. Traditional Flows

Businesses use Salesforce automation to reduce manual work, improve efficiency, and automate repetitive business processes. Two commonly used automation approaches inside Salesforce are Traditional Flows and Flow Orchestrator. Traditional Flows are mainly used for simple automation tasks such as updating records, sending notifications, creating tasks, and automating business logic. Flow Orchestrator is designed for more […]

Read More
The Rise of Agentic Government_ What Salesforce’s 2026 Insights Mean for the Future of Public Sector AI

Government technology has often been seen as slower to evolve than the private sector. But Salesforce’s latest research challenges that idea in a big way. In fact, the new findings suggest that public sector organizations may now be moving faster than many businesses when it comes to adopting AI agents and preparing for a more […]

Read More
How To Use Email Service in APEX

Managing approvals, updates, and record changes directly from email can significantly improve efficiency within Salesforce workflows. Instead of logging in, navigating records, and manually updating fields, users can simply respond to emails and trigger automated updates using Email Service in APEX. This approach is especially useful for businesses leveraging Salesforce automation and looking to enhance […]

Read More
Design and Implementation of Salesforce Jira Task Integration 1 1

Businesses have been using Salesforce for CRM operations and Jira for Agile project tracking. However, without integration, teams manually update both systems, leading to data inconsistency and inefficiency.This mechanism establishes a real-time integration between Salesforce and Jira, allowing seamless synchronization of tasks and agile board statuses.  A custom Salesforce dashboard was developed that replicates Jira-style […]

Read More
Dark Mode in Salesforce Enabling It and Creating Theme Ready Lightning Web Components with SLDS 2.0 1 1

With the Winter ’26 release, Salesforce introduced Dark Mode in Lightning Experience. Dark Mode has been introduced as a beta feature in Winter ’26, and at first it was available only for Starter Edition orgs. It is now rolling out further with Spring ’26 to Professional, Enterprise, and Developer editions. To use Dark Mode, Salesforce […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203239658
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada Canada
HIC Global Solutions INC
6D - 7398 Yonge St #1124 Thornhill, ON L4J 8J2 Canada +1(262) 310-7818