Cloud Pak for Data Group

 View Only

Accelerated Model Realization through API-A solution integrated API Connect and Cloud Pak for Data

By YUAN FENG posted Tue November 16, 2021 05:33 AM


From Gartner
  By 2024, the design mantra for new SaaS and custom applications will be “composable API-first or API-only,” rendering traditional SaaS and custom applications as “legacy.”

“APIs enable companies to more easily build products and services that would otherwise take too long to build,” said Augusto “Aghi” Marietti, the CEO of Kong. “Developers can use these APIs to more easily access business-critical information and focus on other priorities instead.”

APIs can help streamline how customers engage with partners, empower the consumer with more services and options, fasten the delivery and validate the business value in the market.

How to make model realization and evaluate the model value based on the usage or even charged by use? How to quickly turn our existing model into business value? In this article, I try to introduce the integration of API Connect and Cloud Pak for data, make your model API more customer-friendly, and how we can determine which model API has been used most or by whom?

In my prototype, I will show how we can use API connects to reformate the modeling API. And leverage API click to quickly verify which API is used most, promptly deliver the model and validate the value in the market with our partner or customer.

 First, we can new an API connect service and a Waston Machine Learning (WML) service in the IBM Cloud.

Then we can deploy the existing model to Waston Machine Learning; after we deploy the model, we will get an endpoint for the model, but the API to call the model is not friendly for the customer to consume. In my example, I deploy a model to predict customer churn. This is what API you will get from Waston Machine Learning:

curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer $IAM_TOKEN" -d '{"input_data": [{"fields": [$ARRAY_OF_INPUT_FIELDS],"values": [$ARRAY_OF_VALUES_TO_BE_SCORED, $ANOTHER_ARRAY_OF_VALUES_TO_BE_SCORED]}]}' ""

This API doesn’t give what fields this model can accept or what value each field can take. 

Now let’s use API Connect to format this API interface. In the API Connect, you can draft a project and add an API definition to this project.


  1. Specify your API base path
  2. Define each API’s path, API operation, and API input parameter following the open API guide.

    Since my input parameter is an object, you need first to define it. By specifying the input parameter, you can document which property it accepts and the type of the property.

  3. Use the Assemble UI to assemble the callUser can use the gateway script (which support javascript code) to do CPDaaS authentication and transfer the input to model API WML accept.
    var resp = apim.getvariable('message.body')
         apim.setvariable('message.headers.Authorization','Bearer '+ resp.access_token)
    var fields = [
    var inputValue = apim.getvariable('data')
    var data1=[inputValue.age,
    var values =[data1]
    var body={

    You can download the sample model API definition from my GitHub

  4. Add your API to a project and then publish your project to plan. Using the plan, you can control the API support concurrency. After that, you can call with a new endpoint.
    curl --location --request POST '' \
    --header 'APIKey:<key>' \
    --header 'Content-Type: application/json' \
    --data-raw '{

      1. Last, customize our analytics dashboard. Add most active APIs visualization, and you can export the data for more detailed value