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]}]}' "https://us-south.ml.cloud.ibm.com/ml/v4/deployments/0575777d-e0b2-439d-bb55-475736fe240d/predictions?version=2021-11-04"
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.
- Specify your API base path

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

- Use the Assemble UI to assemble the call
User 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')
if(resp){
apim.setvariable('message.headers.Authorization','Bearer '+ resp.access_token)
}
var fields = [
"AGE",
"ACTIVITY",
"EDUCATION",
"NEGTWEETS",
"INCOME",
"SEX",
"STATE"
]
var inputValue = apim.getvariable('data')
var data1=[inputValue.age,
inputValue.activity,
inputValue.education,
inputValue.negtweets,
inputValue.income,
inputValue.sex,
inputValue.state
]
var values =[data1]
var body={
"input_data":[{
"fields":fields,
"values":values
}],
}
apim.setvariable('message.body',body)
apim.setvariable('message.headers.content-type','application/json')
You can download the sample model API definition from my GitHub https://github.com/annfengcn/apic_cpdaas/blob/main/model_example.yaml
- 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 'https://api.us-south.apiconnect.appdomain.cloud/ibm-aps-tools-dsm-dev/sb/cpdapi/model/churn/predict' \
--header 'APIKey:<key>' \
--header 'Content-Type: application/json' \
--data-raw '{
"age":30,
"education":2,
"income":50000,
"activity":2,
"negtweets":1,
"sex":"M",
"state":"CA"
-
Last, customize our analytics dashboard. Add most active APIs visualization, and you can export the data for more detailed value

#CloudPakforDataGroup