Apex
The Seven20 platform includes a set of Apex classes which can be used to invoke generative AI/LLM functionality - these are useful for executing operations which are not viable within standard Salesforce Flow, such as performing additional processing on responses when requesting a structured output.
Large Language Model Service class
The LargeLanguageModelService class is the main entry point for interacting with the LLM functionality and enables LLM requests to be processed through the use of its only visible method performRequest(LargeLanguageModelTextGenerator.Request request).
This method takes a LargeLanguageModelTextGenerator.Request object as a parameter, which contains the input text and other parameters for the LLM request. The method returns a LargeLanguageModelTextGenerator.Response object, which contains the generated text and other information about the request.
The Request and Response classes are specific to each individual LLM model which is being consumed, and are used to define the input and output parameters for the request. As such the specifics of these, outside of the common interface, depend upon the model being used. In general, a request contains a list of messages (List<LargeLanguageModelTextGenerator.ChatMessage>), which are used to define the conversation history and the system messages used to control the generation process. As the content of these requests depends upon the model being used, the specifics of these are not documented here - refer to the model provider's documentation for more information on the specifics of the request and response objects.
Example usage
// Create the chat messages
List<seven20.LargeLanguageModelTextGenerator.ChatMessage> messages = new List<seven20.LargeLanguageModelTextGenerator.ChatMessage>();
messages.add(new seven20.FlowLlmTextGenMessage('user', 'Hello, how are you?')); // Generic seven20.LargeLanguageModelTextGenerator.ChatMessage implementation
// Create a new request object for the GPT-4o model
seven20.LargeLanguageModelTextGenerator.Request req = new seven20.OpenAi.Gpt4o();
req.setMessages(messages);
// Perform the request
seven20.LargeLanguageModelTextGenerator.Response res = seven20.LargeLanguageModelService.performRequest(req);
// Get the generated text from the response
if (!res.isSuccess()) {
System.debug('Error occurred!');
System.debug(res.getErrors());
} else {
System.debug('Success!');
System.debug(res.getResults());
}