'How to Curl an Amazon Sagemaker Endpoint

What is a is the curl command to make a POST request to sage-maker and receive a ML inference?



Solution 1:[1]

Rather than using curl, it's recommended that you use the SageMaker Runtime client to send data and get back inferences from a SageMaker Endpoint:

http://docs.aws.amazon.com/sagemaker/latest/dg/API_runtime_InvokeEndpoint.html

Solution 2:[2]

If you want to simply send a POST request and check, you can use the postman and in the Authorization tab select the AWS Signature and add the Access and Secret key from the aws account.

But as mentioned it is recommended to use the Sage maker run time client for API call invocations.

enter image description here

Solution 3:[3]

This is how I do it (on MacOS):

$ (echo -n '{ INSERT JSON HERE }') | curl -H "Content-Type: application/json" -d @- $ENDPOINT_URL

Solution 4:[4]

If you want to expose your model predicitions to the world I recommend you to follow these tutorials:

You basically need:

  • create an Endpoint using the Sagemaker Estimator
  • use boto3 inside a lambda function to talk to the SageMaker endpoint
  • create an API Gateway so you create a resource to talk to the lambda function from the outside world. e.g. using CURL

Note: there are many permissions involved.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andre
Solution 2 Nirojan Selvanathan
Solution 3 Julien Simon
Solution 4 David I. Rock