---
title: Make Visual AI predictions via the API
dataset_name: N/A
description: Learn how to make predictions on Visual AI projects with API calls.
domain: DSX
expiration_date: 06-01-2022
owner: nathan.goudreault@datarobot.com
url: docs.datarobot.com/en/tutorials/using-the-api/vai-pred.html
---

# Make Visual AI predictions via the API {: #make-visual-ai-predictions-via-the-api }

This tutorial outlines how to make predictions on Visual AI projects with API calls. To complete this tutorial, you must have trained and deployed a visual AI model.

## Takeaways {: #takeaways }

This tutorial shows how to:

* Configure scripting code for making batch predictions via the API
* Make an API call to get batch predictions for a visual AI model
* Format images to a base64 format

## Predictions workflow {: #predictions-workflow }

2. Prepare your data for Visual AI. Before making predictions, convert the images you want to score to [base64 format](vai-predictions#base64-encoding-format) (the standard format for handling images in API calls). Note that when the model returns prediction results, images will return in base64 format. To convert data, use DataRobot's Python package, described in the guide <a target="_blank" href="https://datarobot-public-api-client.readthedocs-hosted.com/page/reference/modeling/spec/binary_data.html#preparing-data-for-predictions">Preparing binary data for predictions</a>.

2. <a name="step-two"></a> After training and deploying a Visual AI model, navigate to the deployment and access the **Predictions > Prediction API** tab. This tab provides the scripting code used to make predictions via the API.

3. To configure the scripting code, select **Batch** as the prediction type and **API Client** as the interface type.

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

4. Copy the code and save it as a Python script (e.g., `datarobot-predict.py`). You can edit the script to incorporate additional steps. For example, add the `passthrough_columns_set` argument to `BatchPredictionJob` if you would like to include columns from the input file (e.g., `image_id`) to the output file.

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

5. Using the scripting code from [step two](#step-two) and a base64-converted image file (`InputDataConverted.csv`), make an API call to get predictions from the deployed model:

    `python datarobot-predict.py InputDataConverted.csv Predictions.csv`

6. Access the output file (`Predictions.csv`) to view prediction results.

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

## Learn More {: #learn-more }

??? tip "Additional tools"

    Reference the <a target="_blank" href="https://github.com/datarobot-community/visual-ai-data-prep/blob/master/visualai_data_prep.py">DataRobot Community GitHub</a> pages for data prep tools, including a script to help with the base64 conversion process. {% include 'includes/github-sign-in.md' %}

    For more information on the scripting code used in this tutorial, refer to the <a target="_blank" href="https://datarobot-public-api-client.readthedocs-hosted.com/">Python Package documentation</a>.

??? tip "Multiclass example"

    For the multiclass classification problem's prediction results in step 6, note that the prediction output file includes the probability of the image falling under each class, the class name with the highest probability, and all the other optional columns requested from the Python scoring script (such as `prediction_status` and `image_id`).

## Documentation {: #documentation }

* [Visual AI overview](../../../modeling/special-workflows/visual-ai/index)
* [Making predictions with Visual AI](vai-predictions)
* [Prediction API overview](../../reference/predapi/index)