# Prediction API snippets

> Prediction API snippets - Use Prediction API snippets for real-time scoring and chat completions
> from generative custom model deployments.

This Markdown file sits beside the HTML page at the same path (with a `.md` suffix). It summarizes the topic and lists links for tools and LLM context.

Companion generated at `2026-04-24T16:03:56.231648+00:00` (UTC).

## Primary page

- [Prediction API snippets](https://docs.datarobot.com/en/docs/agentic-ai/agentic-monitor/agent-pred-api-snippets.html): Full documentation for this topic (HTML).

## Sections on this page

- [Real-time prediction snippet settings](https://docs.datarobot.com/en/docs/agentic-ai/agentic-monitor/agent-pred-api-snippets.html#real-time-prediction-snippet-settings): In-page section heading.
- [Open snippets in a codespace](https://docs.datarobot.com/en/docs/agentic-ai/agentic-monitor/agent-pred-api-snippets.html#open-snippets-in-a-codespace): In-page section heading.

## Related documentation

- [Agentic AI](https://docs.datarobot.com/en/docs/agentic-ai/index.html): Linked from this page.
- [Monitor](https://docs.datarobot.com/en/docs/agentic-ai/agentic-monitor/index.html): Linked from this page.
- [DataRobot Prediction API](https://docs.datarobot.com/en/docs/api/reference/predapi/legacy-predapi/dr-predapi.html): Linked from this page.
- [codespace](https://docs.datarobot.com/en/docs/workbench/wb-notebook/codespaces/index.html): Linked from this page.
- [Use Cases](https://docs.datarobot.com/en/docs/workbench/nxt-workbench/usecases/usecase-overview.html): Linked from this page.

## Documentation content

# 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](https://docs.datarobot.com/en/docs/api/reference/predapi/legacy-predapi/dr-predapi.html). 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, configure Real-time scripts for chat completions and predictions from text generation, agentic workflow, VDB, and MCP custom model deployments. Follow the sample provided and make the necessary changes when you want to integrate the model, via API, into your production application.

> [!NOTE] 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.

### 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) | 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. |
| (4) | Copy script to clipboard | Copies the entire code snippet to your clipboard. |
| (5) | Open in a codespace | Open the snippet in a codespace to edit it, share with others, and incorporate additional files. |
| (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. |

### Open snippets in a codespace

You can open a Prediction API code snippet in a [codespace](https://docs.datarobot.com/en/docs/workbench/wb-notebook/codespaces/index.html) to edit the snippet directly, share it with other users, and incorporate additional files.

To open a Prediction API snippet, click Open in a codespace.

DataRobot generates a codespace instance and populates the snippet inside as a python file.

In the codespace, you can upload files and edit the snippet as needed. For example, you may want to add CLI arguments in order to execute the snippet.

The codespace allows for full access to file storage. You can use the Upload button to add additional datasets for scoring, and have the prediction output ( `output.json`, `output.csv`, etc.) return to the codespace file directory after executing the snippet. This example uploads `10k_diabetes_small.csv` to the codespace as an input file.

To add CLI arguments to the snippet, click Add CLI arguments.

This example references `10k_diabetes_small.csv` as the input file for scoring, and names the output file `output.csv`.

The snippet is now configured to run and return predictions. When you have finished working in the codespace, click Exit and save codespace.

Codespaces belong to [Use Cases](https://docs.datarobot.com/en/docs/workbench/nxt-workbench/usecases/usecase-overview.html), so you must specify an existing Use Case or create a new one to save the codespace to. When a Use Case has been selected, click Exit and save codespace again. Your snippet is now saved in a codespace as part of a Use Case.
