---
title: Prediction API snippets
description: How to adapt downloadable DataRobot Python code to submit a CSV or JSON file for scoring and integrate it into a production application via the Prediction API.

---

# Prediction API snippets {: #prediction-api-snippets }

DataRobot provides sample Python code containing the commands and identifiers required to submit a CSV or JSON file for scoring. You can use this code with the [DataRobot Prediction API](dr-predapi).

You can also read below for more information on:

* [Disabling data drift tracking for individual prediction requests](deploy-inventory#self-managed-ai-platform-deployments-with-monitoring-disabled)

* [Using the monitoring snippet with deployments](#monitoring-snippet)

##  Prediction API scripting code {: #prediction-api-scripting-code }

To use the Prediction API Scripting Code, open the deployment you want to make predictions through and click **Predictions** > **Prediction API**. On the Prediction API Scripting Code page, you can choose from several scripts for **Batch** and **Real-time** predictions. Follow the sample provided and make the necessary changes when you want to integrate the model, via API, into your production application.

To find and access the script required for your use case, configure the following settings:

### Batch prediction snippet settings

![](images/integrations-example.png)

| | Content | Description |
|-|---------|-------------|
| ![](images/icon-1.png) | Prediction type | Determines the prediction method used. Select **Batch**. |
| ![](images/icon-2.png) | Interface | Determines the interface type of the batch prediction script you generate. Select one of the following interfaces:<ul><li>**CLI**: A standalone batch prediction script using the DataRobot API Client. Before using the CLI script, if you haven't already downloaded `predict.py`, click **download CLI tools**.</li><li>**API Client**: An example batch prediction script using the DataRobot's Python package.</li><li>**HTTP**: An example batch prediction script using the raw Python-based HTTP requests. |
| ![](images/icon-3.png) | Platform<br>(*only* for CLI) | When you select the **CLI** interface option, the platform setting determines the OS on which you intend to run the generated CLI prediction script. Select one of the following platform types:<ul><li>**Mac/Linux**</li><li>**Windows**</li> |
| ![](images/icon-4.png) | Copy script to clipboard | Copies the entire code snippet to your clipboard. |
| ![](images/icon-5.png) | Code overview screen| Displays the example code you can download and run on your local machine. You should edit this code snippet to fit your needs. |


### Real-time prediction snippet settings

![](images/integrations-example-2.png)

| | Content | Description |
|-|---------|-------------|
| ![](images/icon-1.png) | Prediction type | Determines the prediction method used. Select **Real time**. |
| ![](images/icon-2.png) | Language | Determines the language of the real-time prediction script generated. Select a format:<ul><li>**Python**: An example real-time prediction script using the DataRobot's Python package.</li><li>**cURL**: A script using cURL, a command-line tool for transferring data using various network protocols, available by default in most Linux distributions and macOS.</li> |
| ![](images/icon-3.png) | Copy script to clipboard | Copies the entire code snippet to your clipboard. |
| ![](images/icon-4.png) | Code overview screen | Displays the example code you can download and run on your local machine. You should edit this code snippet to fit your needs. |


To deploy the code, copy the sample and either:

* Review [deployment options](index)

* Integrate for use with a [dedicated prediction server](dr-predapi)

###  Disable data drift {: #disable-data-drift }

You can disable data drift tracking for individual prediction requests by applying a unique header to the request. This may be useful, for example, in the case where you are using synthetic data that does not have real-world consequences.

Insert the header, `X-DataRobot-Skip-Drift-Tracking=1`, into the request snippet. For example:

```
	headers['X-DataRobot-Skip-Drift-Tracking'] = '1'
	requests.post(url, auth=(USERNAME, API_KEY), data=data, headers=headers)
```

After you apply this header, drift tracking is not calculated for the request. However, service stats are still provided (data errors, system errors, execution time, and more).

###  Monitoring snippet {: #monitoring-snippet }

When you create an external model deployment, you are notified that the deployment requires the use of monitoring snippets to report deployment statistics with the [monitoring agent](../../mlops/deployment/mlops-agent/index).

![](images/integrations-1.png)

You can follow the link at the bottom of the page or navigate to **Predictions** > **Monitoring** for your deployment to view the snippet:

![](images/integrations-2.png)

The monitoring snippet is designed to configure your MLOps library to send a model's statistics to DataRobot MLOps and represent those statistics in the deployment. Use this functionality to report back Scoring Code metrics to your deployment.

To instrument your Scoring Code with a deployment, select the Java language and copy the snippet to your clipboard when you are ready to use it. For further instructions, reference the Quick Start guide available in the monitoring agent internal documentation.

![](images/integrations-3.png)

If you have not yet configured the monitoring agent to monitor your deployment, a download of the MLOps agent tarball is available from a link in the **Monitoring** tab. Additional documentation for setting up the monitoring agent is included in the tarball.

![](images/integrations-4.png)

## Dormant prediction servers {: #dormant-prediction-servers }

Prediction servers become dormant after a prolonged period of inactivity. If you see the **Prediction server is dormant** alert, please contact our support team at support@datarobot.com for prompt reactivation:

![](images/dormant-pred-server-alert.png)
