Skip to content

On-premise users: click in-app to access the full platform documentation for your version of DataRobot.

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. 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.

Dormant prediction servers

Prediction servers become dormant after a prolonged period of inactivity. If you see the Prediction server is dormant alert, contact support@datarobot.com for reactivation.

Batch prediction snippet settings

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

Content Description
1 Prediction type Determines the prediction method used. Select Batch.
2 Interface Determines the interface type of the batch prediction script you generate. Select one of the following interfaces:
  • 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.
  • API Client: An example batch prediction script using DataRobot's Python package.
  • HTTP: An example batch prediction script using raw Python-based HTTP requests.
3 Platform
(for CLI interface only)
Determines the OS on which you intend to run the generated CLI prediction script when you select the CLI interface option. Select one of the following platform types:
  • Mac/Linux
  • Windows
4 Copy script to clipboard Copies the entire code snippet to your clipboard.
5 Show secrets Displays any secrets hidden by ***** in the code snippet. Revealing the secrets in a code snippet can provide a convenient way to retrieve your API key or datarobot-key; however, these secrets are hidden by default for security reasons, so ensure that you handle them carefully.
6 Code overview screen Displays the example code you can download and run on your local machine. Edit this code snippet to fit your needs.

Real-time prediction snippet settings

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

Content Description
1 Prediction type Determines the prediction method used. Select Real time.
2 Language Determines the language of the real-time prediction script generated. Select a format:
  • Python: An example real-time prediction script using DataRobot's Python package.
  • 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.
3 Copy script to clipboard Copies the entire code snippet to your clipboard.
4 Show secrets Displays any secrets hidden by ***** in the code snippet. Revealing the secrets in a code snippet can provide a convenient way to retrieve your API key or datarobot-key; however, these secrets are hidden by default for security reasons, so ensure that you handle them carefully.
5 Code overview screen Displays the example code you can download and run on your local machine. Edit this code snippet to fit your needs.

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).


Updated April 3, 2024