Getting Started
What You'll Build
In this quickstart, you'll use the OpenAI GPT-4o model through the Orchestration Service of AI Core for generating text. The application will send a prompt to the AI model and display the generated response.
Prerequisites
This quickstart assumes you are using the default
resource group of your AI Core instance.
If you want or need to use a different resource group, please ensure that resource group has an orchestration deployment available.
Add the SDK as a Dependency
Add the following dependency to your pom.xml
file:
<dependency>
<groupId>com.sap.ai.sdk</groupId>
<artifactId>orchestration</artifactId>
<!-- Use the latest version here -->
<version>${ai-sdk.version}</version>
</dependency>
Use the Orchestration API
We'll use a client
to interact with the Orchestration service:
var client = new OrchestrationClient();
Next, we'll specify the model we want to use:
var config = new OrchestrationModuleConfig()
.withLlmConfig(OrchestrationAiModel.GPT_4O);
Now we can create our first prompt:
var prompt = new OrchestrationPrompt("Hello world! Why is this phrase so famous?");
var result = client.chatCompletion(prompt, config).getContent();
The result will be the text generated by the AI model.
Run the Application Locally
In order to run the application locally, you need to provide credentials for your AI Core service instance.
For this example we'll use a service key and pass it as an environment variable to the application.
cd your-spring-app/
# assuming a bash, for other shells (e.g. PowerShell) see the below documentation
export AICORE_SERVICE_KEY='{ "clientid": "...", "clientsecret": "...", "url": "...", "serviceurls": { "AI_API_URL": "..." } }'
# assuming Maven and a Spring Boot application
mvn spring-boot:run
Please find detailed instructions and more examples in this documentation.
Explore Further Capabilities
Check out the options available for the OrchestrationPrompt
and OrchestrationModuleConfig
classes.
You can use templating, content filtering, data masking and more.
Please refer to this documentation for more information.