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();
AI Core - Orchestration
<dependency> <groupId>com.sap.ai.sdk</groupId> <artifactId>orchestration</artifactId> <version>1.0.0</version> </dependency>
- 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();
AI Core - Foundation Models
<dependency> <groupId>com.sap.ai.sdk.foundationmodels</groupId> <artifactId>openai</artifactId> <version>1.0.0</version> </dependency>
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();
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
- SAP Cloud SDK for AI for JavaScript released in October 2024.
- Visit sap.com/ai and explore our portfolio
- Explore the available AI capabilities on SAP Discovery Center.
- Discover the latest announcements in the SAP TechEd Press Release and the SAP TechEd News Guide.
- Review the SAP Road Map Explorer for a detailed view of upcoming product innovations.
- Join the SAP Community page to connect with experts and share knowledge.