The SAP Cloud SDK for AI is the official Java SDK for SAP AI Core, SAP Generative AI Hub, and Orchestration Service. The SDK provides type-safe client classes for consuming foundation models, managing AI Core resources, and configuring orchestration features including templating, content filtering, data masking, and document grounding.
The codebase is a Maven multi-module project located at https://github.com/SAP/ai-sdk-java. The parent POM sdk-parent (pom.xml4-5) coordinates build configuration and dependency management across five SDK modules and one sample application module.
Key SDK Artifacts:
com.sap.ai.sdk (core services)com.sap.ai.sdk.foundationmodels (OpenAI client)1.15.0-SNAPSHOT (pom.xml6)Sources: pom.xml4-10 pom.xml16-21 README.md7-13
The SDK enables three integration patterns for consuming AI services on SAP Business Technology Platform:
1. Orchestration Service Integration
OrchestrationClient (orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationClient.java)OrchestrationModuleConfig builder pattern for pipeline modulescom.sap.ai.sdk:orchestration (orchestration/pom.xml9)2. Direct Foundation Model Access
OpenAiClient (foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java)OpenAiModel static constants (GPT-4o, Claude, Gemini, etc.)com.sap.ai.sdk.foundationmodels:openai (foundation-models/openai/pom.xml11)3. AI Core Resource Management
DeploymentApi, ConfigurationApi, ScenarioApi (core/src/main/java/com/sap/ai/sdk/core/client/)AiCoreService for connectivity and deployment resolution (core/src/main/java/com/sap/ai/sdk/core/AiCoreService.java)com.sap.ai.sdk:core (core/pom.xml9)4. Spring AI Framework Integration (Optional)
OrchestrationChatModel, OpenAiChatModel, OrchestrationSpringEmbeddingModelChatModel, EmbeddingModel, ChatOptions<optional>true</optional> (orchestration/pom.xml63-76 foundation-models/openai/pom.xml106-119)Runtime Requirements:
Sources: pom.xml52-67 pom.xml100-113 orchestration/pom.xml9-11 foundation-models/openai/pom.xml11-13 core/pom.xml9-11 orchestration/pom.xml63-76 foundation-models/openai/pom.xml106-119
SDK Module Architecture
Module Definitions
The parent POM (pom.xml31-37) declares the following modules:
| Module Path | Artifact Coordinates | Key Classes/Packages | Purpose |
|---|---|---|---|
core/ | com.sap.ai.sdk:core (core/pom.xml9) | AiCoreServiceDeploymentApiConfigurationApiScenarioApiDeploymentResolver | AI Core connectivity, service binding resolution, deployment caching, generated OpenAPI clients from aicore.yaml (core/pom.xml187) |
orchestration/ | com.sap.ai.sdk:orchestration (orchestration/pom.xml9) | OrchestrationClientOrchestrationModuleConfigOrchestrationPromptOrchestrationChatModel | Orchestration service client with templating, masking, filtering, grounding modules. Generated models from orchestration.yaml (orchestration/pom.xml199) |
foundation-models/openai/ | com.sap.ai.sdk.foundationmodels:openai (foundation-models/openai/pom.xml11) | OpenAiClientOpenAiModelOpenAiChatModelOpenAiEmbeddingModel | Direct OpenAI model access without orchestration. Generated models from openapi-2024-10-21.yaml (foundation-models/openai/pom.xml193) |
core-services/document-grounding/ | com.sap.ai.sdk:document-grounding (core-services/document-grounding/pom.xml10) | Generated API clients Generated models | Document grounding service client. Generated from grounding.yaml (core-services/document-grounding/pom.xml135) |
core-services/prompt-registry/ | com.sap.ai.sdk:prompt-registry (core-services/prompt-registry/pom.xml10) | Generated API clients Generated models | Prompt template management. Generated from prompt-registry.yaml (core-services/prompt-registry/pom.xml152) |
sample-code/spring-app/ | com.sap.ai.sdk.app:spring-app (sample-code/spring-app/pom.xml11) | OrchestrationControllerOpenAiControllerDeploymentControllerSpringAiOrchestrationService | Spring Boot reference application and E2E test suite. Not included in releases (pom.xml800-803) |
Dependency Characteristics
<optional>true</optional> in orchestration (orchestration/pom.xml63-76) and OpenAI (foundation-models/openai/pom.xml106-119) modules-Pgenerate@Beta (README.md56-58)Sources: pom.xml31-37 pom.xml58 pom.xml67 pom.xml100-113 pom.xml295-298 pom.xml676-688 pom.xml800-803 core/pom.xml9 core/pom.xml187 orchestration/pom.xml9 orchestration/pom.xml63-76 orchestration/pom.xml199 foundation-models/openai/pom.xml11 foundation-models/openai/pom.xml106-119 foundation-models/openai/pom.xml193 core-services/document-grounding/pom.xml10 core-services/document-grounding/pom.xml135 core-services/prompt-registry/pom.xml10 core-services/prompt-registry/pom.xml152 sample-code/spring-app/pom.xml11
AI Core Service Integration Architecture
API Layer Characteristics
The SDK provides three API patterns for different use cases:
1. High-Level Service Clients (Recommended for AI Tasks)
chatCompletion(OrchestrationPrompt, OrchestrationModuleConfig), streamChatCompletion(), embed()OrchestrationModuleConfig for pipeline configurationOrchestrationChatResponse, Stream<OrchestrationChatResponse>OpenAiClient.forModel(OpenAiModel.GPT_4O_MINI)chatCompletion(String), streamChatCompletion(), embedding(List<String>)OpenAiChatCompletionOutput, Stream<String>, OpenAiEmbeddingOutput2. Spring AI Framework Adapters (Optional Integration)
org.springframework.ai.chat.model.ChatModelcall(Prompt), stream(Prompt)Prompt → OrchestrationPromptorg.springframework.ai.chat.model.ChatModelMessage → OpenAI request format3. Generated AI Core Management APIs
core/src/main/resources/spec/aicore.yaml (core/pom.xml187)list(resourceGroup), create(resourceGroup, AiDeploymentCreationRequest), get(), delete()query(resourceGroup), create(), get(), update()query(), get()Infrastructure Components
getBaseDestination(), getInferenceDestination(), withResourceGroup(), reloadCachedDeployments()AICORE_SERVICE_KEY environment variableHttpDestination with OAuth authenticationAI-Client-Type: AI SDK Java, AI-Resource-Group: {resourceGroup}Sources: orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationClient.java foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java core/src/main/java/com/sap/ai/sdk/core/AiCoreService.java core/src/main/java/com/sap/ai/sdk/core/DestinationResolver.java core/src/main/java/com/sap/ai/sdk/core/client/ core/pom.xml187
Model Catalog Access Points
The SDK provides foundation model access through two static constant classes:
1. OrchestrationAiModel Constants
orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationAiModel.javaOrchestrationModuleConfig.withLlmConfig(OrchestrationAiModel.GPT_4O)String constantsgpt-4o-2024-08-06)2. OpenAiModel Constants
foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiModel.javaOpenAiClient.forModel(OpenAiModel.GPT_4O_MINI)String constants@Deprecated annotationSupported Model Providers
| Provider | Example Constants | Typical Use Case |
|---|---|---|
| OpenAI | GPT_4O, GPT_4O_MINI, O1, O3_MINI | General chat, reasoning tasks |
| Anthropic | CLAUDE_4_SONNET, CLAUDE_4_5_SONNET | Complex analysis, coding |
GEMINI_2_5_FLASH, GEMINI_2_5_PRO | Multimodal tasks | |
| AWS | NOVA_PRO, NOVA_PREMIER | Enterprise workloads |
| Meta | LLAMA_3_3_70B, LLAMA_3_2_90B_VISION | Open models, vision |
| Mistral AI | MISTRAL_LARGE_LATEST, MISTRAL_SMALL_LATEST | European compliance |
| Cohere | COMMAND_R_PLUS, COMMAND_R | RAG, search |
| SAP | ABAP_1 | SAP-specific tasks |
Model Selection Guidelines
OrchestrationClient with OrchestrationAiModel for pipeline featuresOpenAiClient with OpenAiModel for minimal latencytext-embedding-3-small, text-embedding-3-large)Complete model catalog with versioning information available at page 1.3 (Supported Models).
Sources: orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationAiModel.java foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiModel.java
Processing Flow
OrchestrationModuleConfig Methods
The OrchestrationModuleConfig class (orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationModuleConfig.java) provides fluent configuration:
| Method | Return Type | Purpose |
|---|---|---|
withLlmConfig(OrchestrationAiModel) | OrchestrationModuleConfig | Required: Set model and inference parameters |
withTemplateConfig(TemplatingModuleConfig) | OrchestrationModuleConfig | Optional: Configure prompt templates |
withMaskingConfig(DpiMaskingModuleConfig) | OrchestrationModuleConfig | Optional: Enable PII masking |
withInputFiltering(FilterConfig) | OrchestrationModuleConfig | Optional: Apply input content filters |
withOutputFiltering(FilterConfig) | OrchestrationModuleConfig | Optional: Apply output content filters |
withGrounding(GroundingModuleConfig) | OrchestrationModuleConfig | Optional: Inject context from vector DB |
withTranslationConfig(TranslationConfig) | OrchestrationModuleConfig | Optional: Enable language translation |
All configuration objects follow immutable builder pattern. Intermediate results from each module are accessible via OrchestrationChatResponse.getIntermediateResults() (returns Map<String, Object>). Detailed configuration covered in pages 5.4-5.9.
Sources: README.md129-132 orchestration/pom.xml10-11 docs/blog/Introducing.md56-76
Optional Dependency Configuration
Spring AI dependencies are declared with <optional>true</optional> in:
spring-ai-model and spring-ai-commonsspring-ai-commons and spring-ai-modelspring-ai-bom version 1.1.2 in dependency managementImplementation Classes
| SDK Class | Spring AI Interface | Location |
|---|---|---|
OrchestrationChatModel | ChatModel | orchestration/.../spring/OrchestrationChatModel.java |
OpenAiChatModel | ChatModel | foundation-models/openai/.../spring/OpenAiChatModel.java |
OrchestrationSpringEmbeddingModel | EmbeddingModel | orchestration/.../spring/OrchestrationSpringEmbeddingModel.java |
OrchestrationChatOptions | ChatOptions | orchestration/.../spring/OrchestrationChatOptions.java |
DefaultToolCallingManager | N/A (internal) | Handles ToolCallback conversion |
The implementations delegate to underlying OrchestrationClient and OpenAiClient instances, converting between Spring AI data structures (Prompt, Message) and SDK request types (OrchestrationPrompt, OrchestrationModuleConfig). Page 8 documents Spring AI integration patterns.
Sources: pom.xml108-113 orchestration/pom.xml63-76 foundation-models/openai/pom.xml106-119
Dependency Management Import
The parent POM defines dependency versions in pom.xml98-259 Applications should import the SAP Cloud SDK BOM:
Module Dependencies
Select required modules based on use case:
Current version defined in pom.xml6 Released versions available on Maven Central at https://central.sonatype.com/namespace/com.sap.ai.sdk.
Sources: pom.xml98-113 pom.xml6 README.md74-83
Environment Variable Setup
The SDK resolves AI Core credentials from the AICORE_SERVICE_KEY environment variable. The AiCoreService class (core/src/main/java/com/sap/ai/sdk/core/AiCoreService.java) uses SAP Cloud SDK's ServiceBindingAccessor to resolve this binding.
Credential Resolution Flow
In cloud environments, service bindings are automatically detected from VCAP_SERVICES. The destination resolution is lazy - credentials are only fetched when getBaseDestination() is first called. Alternative authentication approaches documented at page 2.2.
Sources: README.md112-126 core/pom.xml (dependencies on SAP Cloud SDK connectivity)
Orchestration Service Client
Minimal chat completion using OrchestrationClient:
OpenAI Direct Access
Using OpenAiClient without orchestration features:
Deployment Management
Using generated DeploymentApi:
Additional examples for streaming, tool calling, and module configuration available at pages 2.3, 5, and 6.
Sources: README.md86-109 docs/blog/Introducing.md32-103
Spring Boot Reference Implementation
The spring-app module (sample-code/spring-app/pom.xml11) serves dual purposes:
Application Architecture
Module Configuration
com.sap.ai.sdk.app:spring-app (sample-code/spring-app/pom.xml10-11)<skipTests>true</skipTests>, sample-code/spring-app/pom.xml41), run with -DskipTests=falseDemonstrated Features
The OrchestrationService and SpringAiOrchestrationService classes demonstrate:
Runtime Prerequisites
From sample-code/spring-app/README.md8-30:
AICORE_SERVICE_KEY or .env filedefault resource group:
gpt-4o-mini modeltext-embedding-3-small embedding modelRunning the Application
mvn install -DskipTests from repository rootmvn spring-boot:run from sample-code/spring-app/http://localhost:8080mvn spring-boot:run -Dspring-boot.run.arguments="--spring.profiles.active=mcp" (sample-code/spring-app/README.md47)MCP configuration defined in sample-code/spring-app/src/main/resources/application.yml1-22
Detailed application documentation at page 8 (Sample Application).
Sources: sample-code/spring-app/pom.xml10-13 sample-code/spring-app/pom.xml36 sample-code/spring-app/pom.xml41 sample-code/spring-app/README.md1-52 sample-code/spring-app/src/main/resources/application.yml1-22 pom.xml800-803
Compiler Configuration
Java compiler settings defined in pom.xml52-56:
Dependency Versions
Key versions from pom.xml58-74:
| Dependency | Version | Property |
|---|---|---|
| SAP Cloud SDK | 5.25.0 | cloud-sdk.version |
| Spring AI | 1.1.2 | spring-ai.version |
| Spring Framework | 6.2.15 | springframework.version |
| JUnit Jupiter | 6.0.1 | junit-jupiter.version |
| Jackson | 2.20.1 | jackson.version |
Quality Enforcement Plugins
Maven plugins configured in pom.xml606-789:
| Plugin | Configuration | Enforcement Level |
|---|---|---|
| JaCoCo (pom.xml672-752) | Coverage ratios | 100% for complexity, line, instruction, branch, method, class |
| Checkstyle (pom.xml607-635) | .pipeline/checkstyle.xml | Zero violations allowed |
| PMD (pom.xml636-670) | .pipeline/pmd.xml | Zero violations allowed |
| SpotBugs (pom.xml753-773) | .pipeline/spotbugs.xml | Zero violations allowed |
| Spotless (pom.xml459-491) | Google Java Format | Auto-fix in process-sources phase |
| OWASP Check (pom.xml776-789) | CVSS threshold 7.0 | Fail build on high severity CVEs |
Generated code excluded from quality checks via pom.xml676-688 Development setup and build process documented at page 10.
Sources: pom.xml50-96 pom.xml606-789 README.md32-52
AiCoreService Lifecycle
The AiCoreService class (core/src/main/java/com/sap/ai/sdk/core/AiCoreService.java) implements lazy initialization to optimize resource usage:
Method Behavior Matrix
| Method Call | Resolves Service Binding | Loads Deployment List |
|---|---|---|
new AiCoreService() | ❌ No | ❌ No |
withBaseDestination(HttpDestination) | ❌ No | ❌ No |
withResourceGroup(String) | ❌ No | ❌ No |
getBaseDestination() | ✅ Yes (lazy) | ❌ No |
getInferenceDestination(model) | ✅ Yes | ✅ Yes (cached) |
forModel(String) | ✅ Yes | ✅ Yes (cached) |
reloadCachedDeployments() | ✅ Yes | ✅ Yes (forced) |
Deployment Cache Implementation
getInferenceDestination() or forModel()GET /v2/lm/deployments?resourceGroup={group}reloadCachedDeployments() to force cache invalidationImmutability Pattern
AiCoreService follows immutable object design. Configuration methods return new instances:
Thread Safety Implications:
AiCoreService instances across threadsConcurrentHashMap)Detailed architecture documentation at pages 3.2 (Connectivity & Service Integration) and 4.1 (AiCoreService).
Sources: core/src/main/java/com/sap/ai/sdk/core/AiCoreService.java core/src/main/java/com/sap/ai/sdk/core/DeploymentResolver.java docs/adrs/004-core-class-for-service-integration.md70-112
OpenAPI Code Generation Strategy
The SDK uses SAP Cloud SDK's OpenAPI generator plugin (pom.xml295-298) to generate client code and model classes from OpenAPI specifications.
Generation Configuration per Module
| Module | Spec File | Generated Packages | Generation Profile |
|---|---|---|---|
| core | core/src/main/resources/spec/aicore.yaml (core/pom.xml187) | com.sap.ai.sdk.core.client.*com.sap.ai.sdk.core.model.* | -Pgenerate (core/pom.xml160-209) |
| orchestration | orchestration/src/main/resources/spec/orchestration.yaml (orchestration/pom.xml199) | com.sap.ai.sdk.orchestration.model.* | -Pgenerate (orchestration/pom.xml172-220) |
| openai | foundation-models/openai/src/main/resources/spec/openapi-2024-10-21.yaml (foundation-models/openai/pom.xml193) | com.sap.ai.sdk.foundationmodels.openai.generated.model.* | -Pgenerate (foundation-models/openai/pom.xml166-223) |
| document-grounding | core-services/document-grounding/src/main/resources/spec/grounding.yaml (core-services/document-grounding/pom.xml135) | com.sap.ai.sdk.grounding.client.*com.sap.ai.sdk.grounding.model.* | -Pgenerate (core-services/document-grounding/pom.xml108-153) |
| prompt-registry | core-services/prompt-registry/src/main/resources/spec/prompt-registry.yaml (core-services/prompt-registry/pom.xml152) | com.sap.ai.sdk.prompt.registry.client.*com.sap.ai.sdk.prompt.registry.model.* | -Pgenerate (core-services/prompt-registry/pom.xml124-178) |
Generation Command
Run from repository root: mvn clean install -Pgenerate
Quality Enforcement Exclusions
Generated code excluded from static analysis and test coverage:
PMD/Checkstyle Exclusions (pom.xml650-660 pom.xml612-614):
JaCoCo Coverage Exclusions (pom.xml676-688):
Handwritten SDK Facade Layer
Handwritten classes provide developer-friendly APIs over generated models:
| Handwritten Class | Purpose | Wraps Generated |
|---|---|---|
AiCoreService | Service connectivity and deployment resolution | DeploymentApi, ConfigurationApi |
OrchestrationClient | High-level orchestration client | LLMModuleConfig, FilterConfig, etc. |
OpenAiClient | Direct model access facade | Generated OpenAI request/response models |
OrchestrationModuleConfig | Builder for pipeline configuration | Multiple generated config classes |
OrchestrationChatModel | Spring AI adapter | OrchestrationClient + generated models |
OpenAiChatModel | Spring AI adapter | OpenAiClient + generated models |
Generated Code Stability
@Beta (README.md56-58)OpenAPI generation process and workflow automation detailed at page 9.6 (API Specification Management).
Sources: pom.xml295-298 pom.xml612-614 pom.xml650-660 pom.xml676-688 README.md56-58 core/pom.xml160-209 core/pom.xml187 orchestration/pom.xml172-220 orchestration/pom.xml199 foundation-models/openai/pom.xml166-223 foundation-models/openai/pom.xml193 core-services/document-grounding/pom.xml108-153 core-services/document-grounding/pom.xml135 core-services/prompt-registry/pom.xml124-178 core-services/prompt-registry/pom.xml152
Distribution Channels
| Channel | Purpose | URL |
|---|---|---|
| Maven Central | Public releases | https://central.sonatype.com/namespace/com.sap.ai.sdk |
| SAP Artifactory | Daily snapshots | https://common.repositories.cloud.sap/artifactory/build-snapshots-cloudsdk/ |
Snapshot Repository Configuration
Defined in pom.xml43-48:
Release Workflow Overview
The release process is split into two GitHub Actions workflows:
Release Profile Configuration
Release-specific plugins configured in pom.xml804-960:
maven-source-plugin: Attaches source JARs (pom.xml815-828)lombok-maven-plugin: Delomboks source for JavaDoc (pom.xml830-856)maven-javadoc-plugin: Generates JavaDoc JARs (pom.xml858-875)maven-gpg-plugin: Signs artifacts (pom.xml877-889)central-publishing-maven-plugin: Deploys to Maven Central (pom.xml922-931)Complete release process documentation at page 10.5.
Sources: pom.xml43-48 pom.xml804-960 README.md155-157
Sources: README.md134-145
Refresh this wiki
This wiki was recently refreshed. Please wait 7 days to refresh again.