# Automated deployment and replacement of Scoring Code in SAP AI Core
URL: https://docs.datarobot.com/en/docs/workbench/nxt-console/nxt-prediction-environments/nxt-prediction-environment-integrations/nxt-sap-pred-env-integration.html

> Create a DataRobot-managed SAP AI Core prediction environment to deploy and replace DataRobot Scoring Code in SAP AI Core.

# Automated deployment and replacement of Scoring Code in SAP AI Core

> [!NOTE] Availability information
> Automated deployment and replacement of Scoring Code in SAP AI Core is a premium feature, off by default. Integration with SAP AI Core requires bidirectional connectivity between DataRobot and the SAP Business Technology Platform (SAP BTP). Contact your DataRobot representative or administrator for information on enabling this feature.
> 
> Feature flag: Enable the Automated Deployment and Replacement of Scoring Code in SAP AI Core ( Premium feature)

Create a DataRobot-managed SAP AI Core prediction environment to deploy DataRobot Scoring Code in SAP AI Core. With DataRobot management enabled, the external SAP AI Core deployment has access to MLOps features, including automatic Scoring Code replacement.

> [!NOTE] Service health information for external models and monitoring jobs
> Service health information is unavailable for external [agent-monitored deployments](https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/mlops-agent/monitoring-agent/index.html) and deployments with predictions uploaded through a [prediction monitoring job](https://docs.datarobot.com/en/docs/workbench/nxt-console/nxt-monitoring/nxt-monitoring-jobs.html).

## Create an SAP AI Core prediction environment

To deploy a model in SAP AI Core, you first create a custom SAP AI Core prediction environment:

1. Open theConsole > Prediction environmentspage and then click+ Add prediction environment.
2. In theAdd prediction environmentdialog box, configure the prediction environment settings: TheSupported model formatssettings are automatically set toDataRobotandDataRobot Scoring Code onlyand can't be changed, as this is the only model format supported by DataRobot managed SAP AI Core. In addition, SAP AI Core prediction environmentsdo notsupport time series models.
3. In theManagement settings, select the relatedSAP credentialsandSAP resource group. SAP Oauth credentials requiredDataRobot management of Scoring Code in SAP AI Core requires existing SAPCredentials. If you don't have existing credentials, theNo SAP credentials foundalert appears, directing you toManage credentialstocreate SAP AI Core credentials.To create the required credentials, forCredential type, selectSAP OAuth. Then, enter aSAP API URL,Auth URL,Client ID,Client secret, and aDisplay name. To validate and save the credentials, clickSave and sign in.
4. In theMonitoring settings, clickEnable monitoringand optionally, defineEnvironment variables.
5. After you configure the environment settings, clickAdd environment. The SAP AI Core environment is now available from thePrediction environmentspage.

## Deploy a model to the SAP AI Core prediction environment

Once you've created an SAP AI Core prediction environment, you can deploy a model to it:

1. On theRegistry > Modelstab, in the table of registered models, click the registered model containing the version you want to deploy, opening the list of versions. Model supportSAP AI Core prediction environmentsdo notsupport time series models or models without Scoring Code support.
2. From the list of versions, click the Scoring Code enabled version you want to deploy, opening the registered model version panel.
3. In the upper-right corner of any tab in the registered model version panel, clickDeploy.
4. In thePrediction history and service healthsettings, underChoose prediction environment, clickChange.
5. In theSelect prediction environmentpanel, clickSAP AI Core, and then click the prediction environment you want to deploy to.
6. With a SAP AI Core environment selected, underSAP resource plan, select a plan based on the anticipated CPU and memory usage of your prediction workloads. For more information on these resource plans, see theSAP AI Core documentation:
7. (Optional) Open theAdvanced environment settingsand define additionalEnvironment key-value pairsto provide extra parameters to the SAP AI Core deployment interface.
8. Configure the remaining deployment settings, and then clickDeploy model.

While the deployment is Launching, you can monitor the status events on the deployment's Monitoring > Service health tab under Recent activity > Agent activity

## Make predictions in SAP AI Core

After you deploy a model to an SAP AI Core prediction environment, you can use the code snippet from the Predictions > Portable predictions tab to score data.

> [!NOTE] Prediction request payload limit
> The maximum prediction request payload is 1MB (approximately 2000 rows) per request. The provided code snippet splits the prediction payload into multiple requests.

Before you run the code snippet, you must export environment variables containing the secrets associated with the [Service Key used SAP AI Core](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/create-service-key):

| Environment variable | Description |
| --- | --- |
| SAP_AI_API_URL | The URL of the SAP AI Core service. |
| SAP_AI_AUTH_URL | The URL used for authentication with SAP AI Core. |
| SAP_CLIENT_ID | The client ID associated with your SAP AI Core Service Key. |
| SAP_CLIENT_SECRET | The client secret associated with your SAP AI Core Service Key. |

> [!NOTE] Note
> These are the same fields provided when creating a [SAP OAuth credential](https://docs.datarobot.com/en/docs/platform/acct-settings/stored-creds.html).

## Feature considerations

- Only Scoring Code JAR-enabled models are supported.
- Custom models, LLMs, and time series models are not supported.
- Challenger models and model replacement are not supported (challenger prediction servers can't be set to an external or serverless prediction environment).
- Batch monitoring is not supported.
- Only CSV files are supported for predictions. XLSX files are not supported by the code snippet.
- The maximum prediction request payload is 1MB (approximately 2000 rows) per request. The code snippet splits the prediction payload into multiple requests.

---
