{"id":15023860,"url":"https://github.com/sap/ai-sdk-java","last_synced_at":"2026-02-20T12:02:28.969Z","repository":{"id":252791132,"uuid":"829468847","full_name":"SAP/ai-sdk-java","owner":"SAP","description":"Integrate chat completion into your business applications with SAP Cloud SDK for AI. Leverage the Generative AI Hub of SAP AI Core to make use of templating, grounding, data masking, content filtering and more. Access all features of SAP AI Core with the SAP Cloud SDK for AI.","archived":false,"fork":false,"pushed_at":"2025-02-03T04:00:36.000Z","size":4941,"stargazers_count":12,"open_issues_count":7,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-03T05:18:30.978Z","etag":null,"topics":["ai","chat","gen-ai","java","sap-ai-core"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SAP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-16T13:42:44.000Z","updated_at":"2025-02-03T04:00:39.000Z","dependencies_parsed_at":"2024-08-27T09:28:32.936Z","dependency_job_id":"6fdb26b6-a303-44dd-ac03-9a000ec2449a","html_url":"https://github.com/SAP/ai-sdk-java","commit_stats":null,"previous_names":["sap/ai-sdk-java"],"tags_count":4,"template":false,"template_full_name":"SAP/repository-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fai-sdk-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fai-sdk-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fai-sdk-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fai-sdk-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SAP","download_url":"https://codeload.github.com/SAP/ai-sdk-java/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237191390,"owners_count":19269707,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","chat","gen-ai","java","sap-ai-core"],"created_at":"2024-09-24T19:59:32.803Z","updated_at":"2026-02-20T12:02:28.957Z","avatar_url":"https://github.com/SAP.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![build](https://github.com/SAP/ai-sdk-java/actions/workflows/continuous-integration.yaml/badge.svg?branch=main)\n![CodeQL](https://github.com/SAP/ai-sdk-java/actions/workflows/github-code-scanning/codeql/badge.svg)\n[![REUSE status](https://api.reuse.software/badge/git.fsfe.org/reuse/api)](https://api.reuse.software/info/git.fsfe.org/reuse/api)\n[![Fosstars security rating](https://github.com/SAP/ai-sdk-java/actions/workflows/fosstars-report.yml/badge.svg?branch=main)](https://github.com/SAP/ai-sdk-java/blob/fosstars-report/fosstars_report.md)\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/SAP/ai-sdk-java)\n\n# \u003cimg src=\"https://sap.github.io/cloud-sdk/img/logo.svg\" alt=\"SAP Cloud SDK\" width=\"30\"/\u003e SAP Cloud SDK for AI (for Java)\n\n**SAP Cloud SDK for AI** is the official Software Development Kit (SDK) for **SAP AI Core**, **SAP Generative AI Hub**, and **Orchestration Service**.\n\nThis SDK enables developers to seamlessly integrate AI capabilities, such as chat completion, into their Java-based business applications using SAP's Generative AI Hub.\nLeverage powerful features like templating, grounding, data masking, and content filtering to build intelligent applications.\nThe SDK simplifies the setup and interaction with SAP AI Core, allowing you to focus on delivering value through AI integration.\n\n## Table of Contents\n\n- [General Requirements](#general-requirements)\n- [Getting Started](#getting-started)\n    - [What You'll Build](#what-youll-build)\n    - [Prerequisites](#prerequisites)\n    - [Use the Orchestration API](#use-the-orchestration-api)\n    - [Run the Application Locally](#run-the-application-locally)\n    - [Explore Further Capabilities](#explore-further-capabilities)\n- [Documentation](#documentation)\n- [Build the Project](#build-the-project)\n- [FAQs](#faqs)\n- [Contribute, Support and Feedback](#contribute-support-and-feedback)\n- [Security / Disclosure](#security--disclosure)\n- [Code of Conduct](#code-of-conduct)\n- [Licensing](#licensing)\n\n## General Requirements\n\n#### Development Environment\n\nThese are required on the developer side to build and run applications with the SDK:\n\n* **Java JDK**: 17 or higher (21 LTS recommended).\n* **SAP Cloud SDK**: 5.6.0 or later (latest recommended, added as a Maven dependency).\n\n#### SAP AI Core Service instance\n\nTo make of use the services supported by the SDK, you need to have access to an SAP AI Core Service instance. Checkout [how to connect](https://sap.github.io/ai-sdk/docs/java/guides/connecting-to-ai-core).\n\n#### Optional Integrations\n\nThe SDK can be combined with popular Java frameworks. These are not required for core functionality, but version compatibility is listed for reference:\n\n* **Spring AI** ≥ 1.0.0\n* **Spring Boot** ≥ 3.0\n* **CAP Java** ≥ 3.0.0\n\n👉 See an [example `pom.xml`](sample-code/spring-app/pom.xml) in our sample Spring Boot application.\n\n\u003e [!WARNING]  \n\u003e All classes under any of the `...model` packages are generated from an OpenAPI specification and marked as `@Beta`.\n\u003e This means that these model classes are not guaranteed to be stable and may change with future releases.\n\u003e They are safe to use, but may require updates even in minor releases.\n\n## Getting Started\n\n### What You'll Build\n\nIn this quickstart, you'll use the OpenAI GPT-4o model through the [Orchestration Service of AI Core](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/orchestration) for generating text.\nThe application will send a prompt to the AI model and display the generated response.\n\n### Prerequisites\n\nThis quickstart assumes you have a **deployment of the Orchestration service available** in the `default` resource group of your AI Core instance.\nIf you don't have a deployment yet, please refer to [this guide](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/create-deployment-for-orchestration) on how to create one.\n\n### Add the SDK as a Dependency\n\nAdd the following dependency to your `pom.xml` file:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.sap.ai.sdk\u003c/groupId\u003e\n    \u003cartifactId\u003eorchestration\u003c/artifactId\u003e\n    \u003c!-- Use the latest version here --\u003e\n    \u003cversion\u003e${ai-sdk.version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Use the Orchestration API\n\nWe'll use a `client` to interact with the Orchestration service:\n\n```java\nvar client = new OrchestrationClient();\n```\n\nNext, we'll specify the model we want to use:\n\n```java\nvar config = new OrchestrationModuleConfig()\n        .withLlmConfig(OrchestrationAiModel.GPT_4O);\n```\n\nNow we can create our first prompt:\n\n```java\nvar prompt = new OrchestrationPrompt(\"Hello world! Why is this phrase so famous?\");\n\nvar result = client.chatCompletion(prompt, config).getContent();\n```\n\nThe result will be the text generated by the AI model.\n\n### Run the Application Locally\n\nIn order to run the application locally, you need to provide credentials for your AI Core service instance.\n\nFor this example we'll use a **service key** and pass it as an **environment variable** to the application.\n\n```shell\ncd your-spring-app/\n\n# assuming a bash, for other shells (e.g. PowerShell) see the below documentation\nexport AICORE_SERVICE_KEY='{ \"clientid\": \"...\", \"clientsecret\": \"...\", \"url\": \"...\", \"serviceurls\": { \"AI_API_URL\": \"...\" } }'\n\n# assuming Maven and a Spring Boot application\nmvn spring-boot:run\n```\n\nPlease find **detailed instructions** and more examples [in this documentation](https://sap.github.io/ai-sdk/docs/java/guides/connecting-to-ai-core#using-the-aicore_service_key-environment-variable).\n\n### Explore Further Capabilities\n\nCheck out the options available for the `OrchestrationPrompt` and `OrchestrationModuleConfig` classes.\nYou can use templating, content filtering, data masking and more.\nPlease refer to [this documentation](https://sap.github.io/ai-sdk/docs/java/guides/orchestration-chat-completion) for more information.\n\n## Documentation\n\nFor more detailed information and advanced usage, please refer to the following:\n\n- [\u003cimg src=\"sample-code/spring-app/src/main/resources/static/BTP-Cockpit-Logo.png\"/\u003e Connecting to AI Core](https://sap.github.io/ai-sdk/docs/java/guides/connecting-to-ai-core)\n- [\u003cimg src=\"sample-code/spring-app/src/main/resources/static/Orchestration-Logo.png\" width=\"16\"/\u003e Orchestration Chat Completion](https://sap.github.io/ai-sdk/docs/java/guides/orchestration-chat-completion)\n- [\u003cimg src=\"sample-code/spring-app/src/main/resources/static/Open-AI-Logo.svg\" width=\"16\"/\u003e OpenAI Chat Completion](https://sap.github.io/ai-sdk/docs/java/guides/openai-chat-completion)\n- [\u003cimg src=\"https://spring.io/favicon-32x32.png\" width=\"16\"/\u003e Spring AI Integration](https://sap.github.io/ai-sdk/docs/java/guides/spring-ai-integration)\n- [🧰 AI Core Deployment](https://sap.github.io/ai-sdk/docs/java/guides/ai-core-deployment)\n- [\u003cimg src=\"sample-code/spring-app/src/main/resources/static/grounding.png\" width=\"16\"/\u003e AI Core Grounding](https://sap.github.io/ai-sdk/docs/java/guides/document-grounding)\n\nFor updating versions, please refer to the [**Release Notes**](https://sap.github.io/ai-sdk/docs/java/release-notes).\n\n## Build the Project\n\nYou can build the project using Maven:\n\n```shell\nmvn clean install -DskipTests\n```\n\nThis will install the current `SNAPSHOT` version of the project into your local Maven repository.\n\nFor SAP internal development, you can also use `SNAPSHOT` builds from the [internal](https://int.repositories.cloud.sap/ui/repos/tree/General/proxy-build-snapshots-cloudsdk/com/sap/ai/sdk) and [internet-facing](https://common.repositories.cloud.sap/artifactory/build-snapshots-cloudsdk/com/sap/ai/sdk/) Artifactory.\n\n## FAQs\n\n### _\"How to add a custom header to AI Core requests?\"_\n\nThe AI SDK leverages the destination concept from the SAP Cloud SDK to manage the connection to AI Core.\nThis opens up a wide range of possibilities to customize the connection, including adding custom headers.\nThe following shows how to add custom headers to all requests sent to AI Core.\n\n```java\nvar service = new AiCoreService();\nvar destination =\n    DefaultHttpDestination.fromDestination(service.getBaseDestination())\n        .header(\"my-header-key\", \"my-header-value\")\n        .build();\n\n// AI Core client\nservice = service.withBaseDestination(destination);\nDeploymentApi client = new DeploymentApi(service);\n```\n\nFor more information, please refer to the [AI Core connectivity guide](https://sap.github.io/ai-sdk/docs/java/guides/connecting-to-ai-core) and the [SAP Cloud SDK documentation](https://sap.github.io/cloud-sdk/docs/java/features/connectivity/http-destinations).\n\nThere is also a convenient method to add custom headers to single calls through the Orchestration or OpenAI client.\n\n```java\nvar client = new OrchestrationClient();\n\nvar result = client.withHeader(\"my-header-key\", \"my-header-value\").chatCompletion(prompt, config);\n```\n\nFor more information on this feature, see the respective documentation of the [OrchestrationClient](https://sap.github.io/ai-sdk/docs/java/orchestration/chat-completion#custom-headers) and [OpenAIClient](https://sap.github.io/ai-sdk/docs/java/foundation-models/openai/chat-completion#custom-headers).\n\n### _\"There's a vulnerability warning `CVE-2021-41251`?\"_\n\nThis is a known false-positive finding.\nDepending on the tooling any product called \"SAP Cloud SDK\" or similar with a low version number may be marked as vulnerable, incorrectly.\nPlease consider suppressing the warning, [as we do](https://github.com/SAP/ai-sdk-java/blob/main/.pipeline/dependency-check-suppression.xml).\n\n\n### _\"Are there any example projects?\"_\n\nExplore example applications and code snippets:\n\n- [Spring Boot Application Example](sample-code/spring-app)\n\n## Contribute, Support and Feedback\n\nThis project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/SAP/ai-sdk-java/issues).\nContribution and feedback are encouraged and always welcome. \nFor more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).\n\n## Security / Disclosure\n\nIf you find any bug that may be a security problem, please follow our instructions at [in our security policy](https://github.com/SAP/ai-sdk-java/security/policy) on how to report it. \nPlease do not create GitHub issues for security-related doubts or problems.\n\n## Code of Conduct\n\nWe as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. \nBy participating in this project, you agree to abide by its [Code of Conduct](https://github.com/SAP/.github/blob/main/CODE_OF_CONDUCT.md) at all times.\n\n## Licensing\n\nCopyright 2024 SAP SE or an SAP affiliate company and ai-sdk-java contributors. Please see our [LICENSE](LICENSE) for copyright and license information. \nDetailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/SAP/ai-sdk-java).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap%2Fai-sdk-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsap%2Fai-sdk-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap%2Fai-sdk-java/lists"}