Deploy a real-time API service#

You’ve successfully designed and tested an API service with a prediction endpoint. The next step is to actually deploy this API service from the Design node into a production environment!

Publish the API service on the API Deployer#

Recall that our Flow has a prediction model to classify credit card transactions as fraudulent or not. We have packaged this model as a prediction endpoint in an API service, but this service only exists on the Design node (our development environment). It can’t answer real queries yet.

Important

The remaining steps require that you are connected to the API Deployer. Dataiku Cloud users can follow instructions for adding the API node extension. Administrators of self-managed Dataiku instances should follow the reference documentation.

The next step is to publish the API service from the Design node to the Deployer.

  1. If not already open, from the More options menu in the top navigation bar on the Design node, click on API Designer. Select the fraud_detection API service.

  2. Click the Publish on Deployer button.

  3. Click OK, keeping the default version id name (v1).

Dataiku screenshot of the dialog for deploying an API service.

Deploy the API service to the deployment infrastructure#

We now have the API service including the prediction endpoint on the Deployer, but to query the endpoint, we still need to deploy the API service to an infrastructure.

  1. If still on the Design node, from the Applications menu in the right-hand corner of the top navigation bar, click Local (or Remote) Deployer.

  2. On the Deployer homepage, select Deploying API Services.

  3. On the Deployments tab of the API Deployer, find the fraud_detection API service on the left, and click Deploy.

  4. If not already selected in the dialog, choose an infrastructure for the new deployment.

  5. Note the default Deployment ID (which takes the form <api-service-name>-on-<infrastructure-name>).

  6. Click Deploy.

  7. On the Status tab of the new deployment, click Deploy once again.

Dataiku screenshot of API Deployer node displaying services available for deployment.

You now have a prediction endpoint available to serve real-time API calls. Note the dedicated URL for this API endpoint.

Dataiku screenshot of an API endpoint available to serve real-time API calls.

Query the API endpoint#

You can now submit real queries to this service by calling the endpoint URL. The Sample code tab provides snippets for calling the API in various languages, such as Shell (cURL), Python, R, or Java.

  1. Within the Status tab of the prediction endpoint, navigate to the Sample code subtab.

  2. Copy-paste the Shell code into a terminal window.

  3. Execute the live query, and see the prediction for this record returned in real-time.

Dataiku screenshot of the sample code tab to test a prediction endpoint.

You can also run the test queries previously defined in the API Designer of your project.

  1. Still within the Status tab of the prediction endpoint, navigate to the Run and test subtab.

  2. Click Run All.

Now the same queries tested in the API Designer on the Design node have been run on the API node.

Optional: Copy the deployment to another infrastructure#

Important

This section requires having a second deployment infrastructure. If you don’t have this available, feel free to read, but skip completing this section.

When choosing an infrastructure in the previous step, you may have seen pre-configured lifecycle stages. An instance admin can modify these stages as desired, so your options may be different depending on the complexity of your organization’s deployment strategy.

Let’s imagine we have another stage of deployment infrastructure, and all tests on the first deployment infrastructure were successful. We now are ready to copy the existing deployment to a new pool of API nodes.

  1. Still within the Status tab of the API service, click Actions > Copy this deployment at the top right.

  2. Select a new infrastructure, keep the other default values, and click Copy.

The service is now ready to be deployed.

  1. Click Deploy again on the page that opens up for the deployment.

  2. Once the deployment has been updated successfully, click Deployments in the top navigation bar to see that the fraud_detection API service was deployed to the development infrastructure and then to the production infrastructure.

View deployed API service on dev and prod infrastructure.