# Scoring Code in an external environment
URL: https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/deploy-workflows/ext-dr-model-ext-env.html

> How to deploy an exported DataRobot model's Scoring Code in an external environment.

# Deploy Scoring Code in an external environment

With DataRobot MLOps you can register a DataRobot model, create a prediction environment, and deploy that model's Scoring Code package to an external prediction environment, establishing a deployment scenario for that model outside DataRobot.

You can download the monitoring agent packaged with [Scoring Code](https://docs.datarobot.com/en/docs/classic-ui/predictions/port-pred/scoring-code/index.html) from a deployment's Portable Predictions tab or the Deployments inventory.

> [!NOTE] Note
> To access the Scoring Code package, make sure you train your model with Scoring Code enabled. Additionally, this package is only compatible with models running at the command line; it doesn't support models running on the [Portable Prediction Server](https://docs.datarobot.com/en/docs/classic-ui/predictions/port-pred/pps/portable-pps.html).

The monitoring agent packaged with the Scoring Code JAR file is configured for the deployment, allowing you to quickly integrate the agent to report model monitoring statistics back to DataRobot MLOps.

To create and deploy a Scoring Code enabled AutoML model in an external environment, follow the workflow outlined below:

```
graph TB
  A[Select a Scoring Code enabled model] --> B[Register the model]
  B --> C{Create an external prediction environment?}
  C --> |No|D[Deploy the model to an external prediction environment]
  C --> |Yes|E[Add an external prediction environment]
  E --> D 
  D --> F[Download the Java Scoring Code and monitoring agent package]
```

## Select a Scoring Code enabled model

Only models compatible with scoring code (and trained with Scoring Code enabled) provide Scoring Code download as a Portable Prediction option. Scoring Code allows you to export DataRobot's AutoML-generated models as JAR files that you can use outside the platform. DataRobot automatically runs code generation for qualifying models and indicates Scoring Code availability with an [indicator badge](https://docs.datarobot.com/en/docs/reference/pred-ai-ref/leaderboard-ref.html#tags-and-indicators) on the Leaderboard.

[Select a Scoring Code enabled model](https://docs.datarobot.com/en/docs/classic-ui/predictions/port-pred/scoring-code/index.html)

## Register the model

DataRobot AutoML automatically generates models and displays them on the Leaderboard. The [model recommended for deployment](https://docs.datarobot.com/en/docs/reference/pred-ai-ref/model-rec-process.html) appears at the top of the page. To obtain the Scoring Code you need for this process, you can register this or any other model from the Leaderboard as long as the model has the Scoring Code indicator.

[Register a model](https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/registry/dr-model-reg.html)

## Deploy the model's Scoring Code externally

To download a model's scoring code with the monitoring agent included and preconfigured, you must create an external MLOps deployment.

### Add an external prediction environment

To create an external deployment, you need an external prediction environment. Create an external prediction environment if you don't already have one in DataRobot.

[Add an external prediction environment](https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/ext-model-prep/ext-pred-env.html)

### Deploy the model to an external prediction environment

Once you've added an external prediction environment, deploy your Scoring Code enabled model to that external prediction environment.

[Deploy a model to an external prediction environment](https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/deploy-methods/deploy-model.html#deploy-a-registered-model)

### Download the Java Scoring Code and monitoring agent package

You can download the monitoring agent packaged with [Scoring Code](https://docs.datarobot.com/en/docs/classic-ui/predictions/port-pred/scoring-code/index.html) from a deployment's Portable Predictions tab or the Deployments inventory. The monitoring agent that comes packaged with the Scoring Code JAR file is already configured for the deployment, allowing you to quickly integrate the agent from the command line using a snippet provided on the Scoring Code download page.

[Download the Scoring Code package](https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/mlops-agent/monitoring-agent/agent-sc.html)

---
