Skip to content

Instantly share code, notes, and snippets.

@gleeb
Created August 11, 2022 08:00
Show Gist options
  • Save gleeb/de502956b3255284c6a9a58f3c3224c9 to your computer and use it in GitHub Desktop.
Save gleeb/de502956b3255284c6a9a58f3c3224c9 to your computer and use it in GitHub Desktop.
sagemaker invoke real time endpoint
import boto3
sm_client = boto3.client('sagemaker', region_name='us-east-1')
sagemaker_runtime = boto3.client("sagemaker-runtime", region_name='us-east-1')
# The name of the endpoint. The name must be unique within an AWS Region in your AWS account.
endpoint_name='titanic-survival-endpoint1'
# After you deploy a model into production using SageMaker hosting
# services, your client applications use this API to get inferences
# from the model hosted at the specified endpoint.
response = sagemaker_runtime.invoke_endpoint(
EndpointName=endpoint_name,
Body=b'1, 1, 25, 1, 1, 8, 1',
ContentType='text/csv',
Accept='text/csv')
print(response)
print(eval(response['Body'].read()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment