AWS SageMaker
Route to your AWS Sagemaker models through Portkey
Sagemaker allows users to host any ML model on their own AWS infrastructure.
With portkey you can manage/restrict access, log requests, and more.
Provider Slug. sagemaker
Portkey SDK Integration with AWS Sagemaker
1. Install the Portkey SDK
Add the Portkey SDK to your application to interact with Sagemaker’s API through Portkey’s gateway.
2. Initialize Portkey with a Virtual Key
There are multiple ways to integrate Sagemaker with Portkey. You can use your AWS credentials, or use an assumed role.
In this example we will create a virtual key and use it to interact with Sagemaker. This helps you restrict access (specific models, few endpoints, etc).
Create a virtual key in the Portkey dashboard in the virtual keys section. You can select sagemaker as the provider, and fill in deployment details.
Initialize the Portkey SDK with the virtual key. (If you are using the REST API, skip to next step)
3. Invoke the Sagemaker model
Making Requests without Virtual Keys
If you do not want to add your AWS details to Portkey vault, you can also directly pass them while instantiating the Portkey client.
These are the supported headers/parameters for Sagemaker (Not required if you’re using a virtual key):
Node SDK | Python SDK | REST Headers |
---|---|---|
awsAccessKeyId | aws_access_key_id | x-portkey-aws-access-key-id |
awsSecretAccessKey | aws_secret_access_key | x-portkey-aws-secret-access-key |
awsRegion | aws_region | x-portkey-aws-region |
awsSessionToken | aws_session_token | x-portkey-aws-session-token |
sagemakerCustomAttributes | sagemaker_custom_attributes | x-portkey-amzn-sagemaker-custom-attributes |
sagemakerTargetModel | sagemaker_target_model | x-portkey-amzn-sagemaker-target-model |
sagemakerTargetVariant | sagemaker_target_variant | x-portkey-amzn-sagemaker-target-variant |
sagemakerTargetContainerHostname | sagemaker_target_container_hostname | x-portkey-amzn-sagemaker-target-container-hostname |
sagemakerInferenceId | sagemaker_inference_id | x-portkey-amzn-sagemaker-inference-id |
sagemakerEnableExplanations | sagemaker_enable_explanations | x-portkey-amzn-sagemaker-enable-explanations |
sagemakerInferenceComponent | sagemaker_inference_component | x-portkey-amzn-sagemaker-inference-component |
sagemakerSessionId | sagemaker_session_id | x-portkey-amzn-sagemaker-session-id |
sagemakerModelName | sagemaker_model_name | x-portkey-amzn-sagemaker-model-name |
Example
Next Steps
The complete list of features supported in the SDK are available on the link below.
SDK
You’ll find more information in the relevant sections:
Was this page helpful?