Skip to main content

API Integration - Python

Now that you've deployed your models on Konan, you'll probably want to integrate them into your processes and get the model's predictions when needed. For example, you can have a backend application that implements a set of functionalities and one which requires getting predictions from your model. It would be convenient to have a function to easily send requests to that model and get its predictions. For that reason, we have created a simple Konan SDK with the main functionalities implemented.

note

As of the current version, only a python implementation of the SDK is available. We intend to support a wider range of languages in coming versions as well as extend the currently implemented functionalities. To see how you can implement your own integration, head over to other implementations.

Prerequisites:​

  • You have python 3.7+
  • You are a registered user on Konan
  • You have a successful deployment running on Konan

Installation​

pip install konan-sdk

Usage​

integration.py
from konan_sdk.sdk import KonanSDK

if __name__ == '__main__':
# Initialize the SDK. Set verbose to True if you want verbose logging.
sdk = KonanSDK(verbose=False)

# Login user your valid konan credentials
user = sdk.login("<email>", "<password>")

# Define the input data to be passed to your model
input_data = {"feature_1": 1, "feature_2": "abc", }

# Run the prediction
prediction_uuid, ml_output = sdk.predict("<deployment_uuid>", input_data)

# Print the returned output
print(prediction_uuid, ml_output)

Most frequently used SDK functions:

  • login(): login to Konan with your credentials
  • predict(): send prediction requests to your deployed model
  • feedback(): send ground truth/feedback on your model's predictions

The complete sdk docs can be found here