REST API

Seldon Deploy’s REST API

Seldon Deploy’s REST API allows you to interact with your machine learning deployments through programmatically.

Versioning

The API endpoints are versioned to avoid clashes between different versions of the API. The current version of the API is v1alpha1, which means that breaking changes are still highly likely to happen. Once the current version graduates to stable, it will be renamed to v1.

Note that this versioning schema is similar to the one followed in Kubernetes.

Authentication

All requests to the Seldon Deploy API must be authenticated. Therefore, before using the API you must obtain an authentication token. This authentication token can then be used to authenticate requests by setting the Authorization header with the following format:

Authorization: Bearer $TOKEN

The Seldon Deploy API leverages OpenID to authenticate and authorize users. Thus, this authentication token can be issued and managed by an OIDC provider. Note that the process to issue a new authentication token may change depending on your architecture and your OIDC provider.

Example

As an example, let’s assume a set up where Keycloak is configured as an OIDC provider and there is an OpenID client named seldon-deploy.

With the above in place, you could obtain an authorization token to access the API using plain cURL as:

SD_USER="data-scientist-1@example.com"
SD_PASSWORD="12341234"
CLIENT_ID="seldon-deploy"

KEYCLOAK_HOST="https://auth.example.com"
KEYCLOAK_REALM="machine-learning"

_payload="username=$SD_USER&password=$SD_PASSWORD&grant_type=password&client_id=$CLIENT_ID&scope=openid"
_authEndpoint="$KEYCLOAK_HOST/auth/realms/$KEYCLOAK_REALM/protocol/openid-connect/token"
RESULT=$(curl -k -s --data $_payload $_authEndpoint)
TOKEN=$(echo $RESULT | sed 's/.*id_token":"//g' | sed 's/".*//g')

echo "TOKEN=$TOKEN"

Once we have obtained this token, we can then use it to authorize our requests to the Seldon Deploy API. For example, to list all our machine learning deployments we could do:

ML_PLATFORM_HOST="https://ml.example.com"

curl -k -X GET \
  "$ML_PLATFORM_HOST/seldon-deploy/api/v1alpha1/mldeployments?namespace=staging" \
  -H "Authorization: Bearer $TOKEN"

Reference


API Reference (v1alpha1)

Reference for version v1alpha1 of the API.

Last modified July 22, 2020: Add authentication section (edbfbc8)