Unable to Connect api gateway with sagemaker endpoint

0

i have created a personal studio in sagemaker and deployed my custom fastapi code using docker and on sgemaker studio UI I'm able to test the invocation but while trying with AWS apigateway its giving 404 with <UnknownOperationException/>

and when trying with boot 3

import boto3

import json client = boto3.client('sagemaker-runtime') payload = { "session_id": "ccccccccccc", "user_name": "mfxxxx@gmail.com", "analytical_query": "something " }

endpoint_name = 'Insight-xxxxx-Endpoint-2024xxx-05xxxx' content_type = 'application/json' payload = json.dumps(payload) response = client.invoke_endpoint( EndpointName=endpoint_name, ContentType=content_type, Body=payload )

botocore.errorfactory.ValidationError: An error occurred (ValidationError) when calling the InvokeEndpoint operation: Inference Component Name header is required for endpoints to which you plan to deploy inference components. Please include Inference Component Name header or consider using SageMaker models.

2 Answers
1

Hello Hope you are doing well.

From the error code that you have shared, it seems that you created endpoint using Sagemaker inference component feature. If that was the case, please include the InferenceComponentName in the invoke_endpoint call to invoke the endpoint.

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker-runtime/client/invoke_endpoint.html#:~:text=InferenceComponentName%3D%27string%27

AWS
answered 5 days ago
  • Thanks lavaraja

    i have not created any inference component I have only created one endpoint

0

Hello,

Thank you for confirming that you did not have inference component associated. Can you please share the steps you followed to create the endpoint? Please mask the information wherever applicable before sharing.

And regarding Sagemaker endpoint invocation using API gateway, you might refer below example blog.

https://aws.amazon.com/blogs/machine-learning/creating-a-machine-learning-powered-rest-api-with-amazon-api-gateway-mapping-templates-and-amazon-sagemaker/

AWS
answered 3 days ago
  • have been following the same but i don't want to use vtl I want one direct connection so I have created an direct post connection with sagemaker

  • Hello Lalit,

    Thank you for providing more details. I see there are 2 issues mentioned in the post.

    In order to understand where the issue lies, I would like you to perform below.

    1. Try invoking the endpoint first to see the endpoint is responding with out issues. you can use AWS CLI. or boto3.

    If you are able to invoke the endpoint using CLI/Boto3 then please cross check your API gateway configuration and parameter mapping. Here is the API definition for invoking Sagemaker endpoint.

    [+] https://stackoverflow.com/questions/54691487/how-can-i-call-sagemaker-inference-endpoint-using-api-gateway

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions