Skip to content

Latest commit

 

History

History
104 lines (79 loc) · 3.26 KB

AI_CORE_DEPLOYMENT.md

File metadata and controls

104 lines (79 loc) · 3.26 KB

AI Core Deployment

Table of Contents

Introduction

This guide provides examples on how to create and manage deployments in SAP AI Core using the SAP AI SDK for Java.

Prerequisites

Before using the AI Core module, ensure that you have met all the general requirements outlined in the README.md. Additionally, include the necessary Maven dependency in your project.

Maven Dependencies

Add the following dependency to your pom.xml file:

<dependency>
    <groupId>com.sap.ai.sdk</groupId>
    <artifactId>core</artifactId>
    <version>${ai-sdk.version}</version>
</dependency>

See an example pom in our Spring Boot application

Usage

In addition to the prerequisites above, we assume you have already set up the following to carry out the examples in this guide:

  • An AI Core Configuration created in SAP AI Core.
    • Example configuration from the AI Core /configuration endpoint
      {
        "createdAt": "2024-07-03T12:44:08Z",
        "executableId": "azure-openai",
        "id": "12345-123-123-123-123456abcdefg",
        "inputArtifactBindings": [],
        "name": "gpt-35-turbo",
        "parameterBindings": [
          {
            "key": "modelName",
            "value": "gpt-35-turbo"
          },
          {
            "key": "modelVersion",
            "value": "latest"
          }
        ],
        "scenarioId": "foundation-models"
      }

Create a Deployment

Use the following code snippet to create a deployment in SAP AI Core:

var api = new DeploymentApi(new AiCoreService().client());
var resourceGroupId = "default";

AiDeploymentCreationRequest request =
    AiDeploymentCreationRequest.create().configurationId("12345-123-123-123-123456abcdefg");
AiDeploymentCreationResponse deployment = api.create(resourceGroupId, request);

var id = deployment.getId();
AiExecutionStatus status = deployment.getStatus();

Refer to the DeploymentController.java in our Spring Boot application for a complete example.

Delete a Deployment

AiDeploymentCreationResponse deployment; // provided
String deploymentId = deployment.getId();
  
var api = new DeploymentApi(new AiCoreService().client());
var resourceGroupId = "default";
  
if (deployment.getStatus() == AiExecutionStatus.RUNNING) {
  // Only RUNNING deployments can be STOPPED
  api.modify(
    resourceGroupId,
    deploymentId,
    AiDeploymentModificationRequest.create().targetStatus(AiDeploymentTargetStatus.STOPPED));
}
// Wait a few seconds for the deployment to stop
// Only UNKNOWN and STOPPED deployments can be DELETED
api.delete(resourceGroupId, deployment.getId());

Refer to the DeploymentController.java in our Spring Boot application for a complete example.