Salesforce Models API
805 views
Mar 4, 2025
Salesforce Models API provides Apex classes and REST endpoints that can be used in your application to interact with the large language models (LLMs) from the Salesforce partners, including Anthropic, Google, and OpenAI. Blog Post: https://www.infallibletechie.com/2025/03/salesforce-models-api.html
View Video Transcript
0:07
hello everyone in this video we are
0:09
going to see Salesforce models
0:13
API using Salesforce models API we can
0:18
access llm
0:20
models we can make use of Salesforce
0:23
Apex or we can also make use of rest API
0:28
to connect to the models API
0:30
and then we can generate the responses
0:33
using the llm
0:35
models Salesforce supports specific set
0:39
of llm models it has partnered with
0:44
other providers so that we can make use
0:47
of those llm models using Salesforce
0:51
models
0:53
API in in your business use
0:57
cases the potential use cases are you
1:01
can generate a text so you can choose
1:03
any model and then you can uh send your
1:06
prompt it will generate a text for you
1:10
similarly you can generate chart you can
1:13
send your whole chart conversation and
1:16
then you can it will send you the
1:19
summary or based on the model whatever
1:22
you are selecting it will generate the
1:24
response and then you will be able to
1:25
process it you can also generate
1:29
embeddings embedding is numerical
1:32
representation of
1:35
objects which machine uh language or
1:40
natural uh language processing machine
1:43
can understand
1:45
it you can
1:47
also uh generate feedback let's say you
1:50
are
1:51
trying multiple models and then you
1:54
wanted to uh share a feedback and then
1:57
later you wanted to run a report
2:00
uh based on the feedbacks that are
2:02
shared and then if you wanted to see
2:03
which model is doing good if that is
2:05
your use case then you should be able to
2:08
submit feedback to these models also for
2:11
whenever you submit the feedback it will
2:14
be stored in Salesforce data clod so you
2:16
will be able to review
2:19
it let's
2:22
see how
2:24
to invoke models CPI using Salesforce
2:28
Apex in in this Salesforce Apex code I
2:32
am making use of open AA gp4 Omni
2:39
GPD model in order to set it I am
2:43
setting the model name as sfdc _ aaor
2:48
default
2:50
GPT for
2:54
Omni if you come to this blog post
3:01
you will be able to see a link to
3:05
Salesforce developer article if you go
3:08
through this article you will be able to
3:10
find the
3:12
supported large language
3:15
models you can also bring your own LM
3:20
model um you can go over this article
3:23
and then you will be able to understand
3:26
more in detail
3:30
so here in this
3:32
uh particular Apex code I'm sending a
3:35
prompt saying what are what are the best
3:38
restaurants in Toronto Ontario Canada so
3:42
this is my
3:44
prompt and I making use
3:46
of models API do create Generations
3:50
uncore request so I'm making use of this
3:54
use case generate
3:58
text let's look at the logs before that
4:01
let me clear all the lcks so I'm
4:03
executing the
4:08
code and I'm making use of uh open AA
4:13
GPD 4
4:17
Omni and uh this is the response I got
4:21
it from
4:22
the llm
4:28
model so in your your business use cases
4:32
if you wanted to
4:34
invoke a model and then you wanted to
4:37
process the data and then store or
4:39
summarize what might be any use case for
4:43
you then you can easily make use of
4:44
models API from Apex and then you should
4:47
be able to process it if you are using a
4:49
screen flow um you can uh invoke the
4:54
Apex from the flow and then you should
4:56
be able to process it
5:01
let's say your use case is not from Apex
5:04
and you wanted to uh process it using uh
5:09
API U because we have concurrent Apex
5:12
and other limitations in Salesforce so
5:14
if you want if you have your
5:16
requirements to be done as part of APA
5:19
uh for example if you are going to use a
5:21
third party application to invoke uh um
5:25
uh model API then you can create a
5:28
Connected app in Salesforce
5:31
um this block post will be shared in the
5:34
video description so using this uh block
5:37
post you should be able to create a
5:39
Connected app if you go to the
5:41
Salesforce agent APA block post I have
5:45
given six steps to create a Connected
5:48
app once the Connected app is created we
5:51
have to get the access token in the same
5:54
block post I have given how to generate
5:56
the access
5:57
token next we have to make use of a post
6:01
request to https colon slap.
6:06
salesforce.com Einstein SL platform
6:10
slv1 SL models SL the model API name
6:15
here I'm making use of the same opena
6:18
gp4 Omni
6:20
model in the header you have to send
6:23
content type as application or Json
6:26
authorization as bar space access token
6:29
once you get it once you get the access
6:32
token and uh x i sfdc iph app iph
6:37
context we have to say Einstein GPD in
6:41
the x i client iph feature iph ID we
6:45
have to pass AI I platform I models I
6:51
connected I
6:53
app in the body you have to send the
6:56
prompt because I'm making use of
6:58
generations I'm not making use of other
7:00
use cases as part of this video so I'm
7:03
going to send a prompt and it should
7:06
return the
7:07
response let's see how to do that so
7:10
first this is my
7:12
org um I'm making use of client
7:14
credentials flow and then I'm getting
7:17
the access token so I got the access
7:21
token this is the
7:24
header and this is the
7:27
body so now my access token is is ready
7:30
I have a script which runs and stores
7:33
the access
7:35
token here we talked about this header
7:39
this is the end
7:41
point in the body we have to send what
7:44
is the
7:45
prompt in the header make sure you are
7:47
using bar space the access token which
7:50
you did it in the previous post
7:56
request and then if you send a post
7:59
request it will be able to generate the
8:02
content based on the prompt whatever you
8:08
send one more important thing
8:12
is if you are worried about the toxicity
8:15
then you should be able to see the
8:17
toxicity score
8:19
also the toxicity score will be 0 to 1
8:23
one is the
8:24
highest so you can make use of this
8:26
toxicity score and then uh you can store
8:30
it um if you are using a third party
8:32
application and then if you are invoking
8:34
you can store those information in your
8:36
third party application and then you can
8:38
report and review it
8:44
later if you wanted to know more about
8:47
the toxicity scoring then you can make
8:49
use of this Salesforce developer
8:56
article please check the video
8:58
description in the video description I
9:00
have shared my blog post from the blog
9:02
post you should be able to get the
9:03
sample Apex code which was referenced in
9:06
this video and also other additional
9:09
help links uh which can be referenced
9:14
for
9:15
invoking models
9:24
API I hope it was helpful
9:32
thank you for watching
#Business & Industrial
#Computers & Electronics
#Intelligent Personal Assistants
#Internet & Telecom
#Internet Software
#Software