13

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

tlanigan
  • 849
  • 1
  • 9
  • 20
  • 3
    @JohnRotenstein This question is actually pretty clear if you have a decent level of exposure to SageMaker. [Googling 'sagemaker post inference"](https://www.google.com/search?q=sagemaker+post+inferance) gives the second response that should cover any [missing background](https://docs.aws.amazon.com/sagemaker/latest/dg/API_runtime_InvokeEndpoint.html) on what the OP is asking. –  Jan 18 '18 at 18:32

4 Answers4

9

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

Nirojan Selvanathan
  • 10,066
  • 5
  • 61
  • 82
4

This is how I do it (on MacOS):

$ (echo -n '{ INSERT JSON HERE }') | curl -H "Content-Type: application/json" -d @- $ENDPOINT_URL
Julien Simon
  • 2,605
  • 10
  • 20
2

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

Andre
  • 530
  • 3
  • 15
0

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.

David I. Rock
  • 95
  • 2
  • 4