Integrate a Deployment
This article described how to seamlessly integrate your Deployment with other (business) applications. The integration process involves two steps:
- Generating a Deployment API Token
- Using the integration code and Deployment token to integrate the Deployment into your application.
Alternatively, interact with a Deployment using the Deeploy Python client. To authenticate with OpenID Connect, configure OpenID Connect first.
To start, navigate to the deployment you want to integrate by selecting it from the Deployment overview.
Generating a Deployment API token
Next, navigate to the Authentication page and create a new token.
The following elements can be configured for a token:
- Token name: name of the token
- Description (optional): description to clarify what the token is used for
- Valid until (optional): token will be invalid after the supplied date
After creating a token, a pop-up appears with the Deployment API token. The Deployment API Token is a Bearer Token used in the Authorization Header of a HTTP request.
Make sure to copy and store the token somewhere else immediately, as you cannot recover the token once you close the pop-up.
Using the integration code snippet
Next, navigate to the Code snippets page. Deeploy provides code snippets for three different environments (see figure below):
- Node.js
- Python
- Bash
The snippets require you to enter your token and your input tensor For your convenience, the code snippets for the three environments are included in this article as well.
- Node.js
- Python
- Bash
var request = require('request');
// EXAMPLE: a batch prediction with two input tensors
const model_input = {
"instances": [
[0,1,0,1],
[1,0,1,0]
]
};
const options = {
method: 'POST',
url: '<DEPLOYMENT_API>/<METHOD>',
json: model_input,
auth: {
bearer: '<YOUR_TOKEN_HERE>',
},
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
const model_output = body;
});
import requests
token = '<YOUR_TOKEN_HERE>'
deployment_url = '<DEPLOYMENT_API>/<METHOD>'
# Example: a batch prediction with two input tensors
model_input = {
"instances": [
[0,1,0,1],
[1,0,1,0]
]
}
headers = {
'Authorization': 'Bearer %s' % token,
}
response = requests.post(deployment_url, headers=headers, json=model_input)
model_output = response.json()
curl -X POST "<DEPLOYMENT_API>/<METHOD>" \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
-d '{ "instances": [[0,1,0,1],[1,0,1,0]]}'