Technology Blog Posts by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
newtork
Product and Topic Expert
Product and Topic Expert
2,682

We’re excited to announce the initial release of the SAP Cloud SDK for AI for Java! Only a few weeks ago we already announced the release of the JavaScript/TypeScript variant. Similarly, this SDK for Java enables convenient integration of generative AI capabilities within your SAP Business Technology Platform (BTP) applications and allows you to utilize the Generative AI Hub in SAP AI Core.

For SAP BTP developers, the AI SDK is crafted to simplify AI integration and enhance application impact. With features that optimize deployment, improve content safety, and facilitate model orchestration, the SDK lets you bring advanced AI functionality to your applications swiftly and with minimal setup. Whether you need adaptable workflows, secure data handling, or smooth generative model integration, the SDK equips you with robust tools to embed AI-powered features in your SAP BTP solutions.

This post introduces the main modules and their features.

 

AI Core - Setup and Usage

<dependency>
  <groupId>com.sap.ai.sdk</groupId>
  <artifactId>core</artifactId>
  <version>1.0.0</version>
</dependency>

Automate tasks such as creating AI Core artifacts, configurations, and deployments, executing batch inference jobs, as well as managing Docker registries and object storage for training data. The core module provides tools for workflow and scenario management within SAP AI Core.

  • Artifact management: register and organize datasets and model artifacts.
  • Configuration management: set up configurations for various models and use cases.
  • Deployment management: deploy AI models and manage their lifecycle within SAP AI Core.

Example SDK code: Create a deployment in SAP AI Core.

var api = new DeploymentApi();
var resourceGroupId = "default";
var request = AiDeploymentCreationRequest.create().configurationId("12345-123-123-123-123456abcdefg");

AiDeploymentCreationResponse deployment = api.create(resourceGroupId, request);
String id = deployment.getId();
AiExecutionStatus status = deployment.getStatus();
You can learn more about the SDK's capabilities for SAP AI Core in the public repository guide.
 

AI Core - Orchestration

<dependency>
  <groupId>com.sap.ai.sdk</groupId>
  <artifactId>orchestration</artifactId>
  <version>1.0.0</version>
</dependency>
This orchestration module lets you use the Generative AI Hub Orchestration Service with templating, content filtering, and data masking from within your applications. The Orchestration Service streamlines AI interactions while ensuring adherence to content safety guidelines.
  • Templating: Build dynamic prompts with placeholders to tailor AI interactions to user inputs.
  • Content Filtering: Apply filters to maintain compliance with content safety guidelines.
  • Data Masking: Anonymize and pseudonymize sensitive data.
  • Grounding: Add external data sources for contextually relevant information (planned for Q1 2025).

Example SDK code: Write a simple chat completion.

var client = new OrchestrationClient();
var config = new OrchestrationModuleConfig().withLlmConfig(OrchestrationAiModel.GPT_4O);
var prompt = new OrchestrationPrompt("Hello world! Why is this phrase so famous?");
var result = client.chatCompletion(prompt, config);

String messageResult = result.getContent();
You can learn more about the SDK's capabilities for Orchestration Service in the public repository guide.
 

AI Core - Foundation Models

<dependency>
  <groupId>com.sap.ai.sdk.foundationmodels</groupId>
  <artifactId>openai</artifactId>
  <version>1.0.0</version>
</dependency>
The openai module, along with other modules in the com.sap.ai.sdk.foundationmodels group, enables streamlined access to specific generative AI models available through the Generative AI Hub. The module provides a simplified interface focused on direct model interactions, ideal for developers who require direct access to foundation models for inference and embedding requests without additional orchestration features.

Currently only openai is supported. Please open a feature request, if you need direct LLM access for other foundation models.

Example SDK code: Write a simple chat completion.

var result = 
  OpenAiClient.forModel(GPT_35_TURBO)
    .withSystemPrompt("You are a helpful AI")
    .chatCompletion("Hello World! Why is this phrase so famous?");

String resultMessage = result.getContent();
You can learn more about the SDK's capabilities for foundation models and OpenAI specific features in the public repository guide.
 

Getting Started

You will need Java 17 or higher. Spring Boot or SAP Cloud Application Programming Model (CAP) as a framework is recommended, but not required. To explore these packages further, check out our sample project, which shows the usage of the various SDK packages.

 

Support and Feedback

We’d love your feedback on this first release! For support or to share your ideas, feel free to open an issue on GitHub.

 

Latest News

2 Comments