- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
InvokeEndpointCommand
After you deploy a model into production using Amazon SageMaker hosting services, your client applications use this API to get inferences from the model hosted at the specified endpoint.
For an overview of Amazon SageMaker, see How It Works .
Amazon SageMaker strips all POST headers except those supported by the API. Amazon SageMaker might add additional headers. You should not rely on the behavior of headers outside those enumerated in the request syntax.
Calls to InvokeEndpoint
are authenticated by using Amazon Web Services Signature Version 4. For information, see Authenticating Requests (Amazon Web Services Signature Version 4) in the Amazon S3 API Reference.
A customer's model containers must respond to requests within 60 seconds. The model itself can have a maximum processing time of 60 seconds before responding to invocations. If your model is going to take 50-60 seconds of processing time, the SDK socket timeout should be set to be 70 seconds.
Endpoints are scoped to an individual account, and are not public. The URL does not contain the account ID, but Amazon SageMaker determines the account ID from the authentication token that is supplied by the caller.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { SageMakerRuntimeClient, InvokeEndpointCommand } from "@aws-sdk/client-sagemaker-runtime"; // ES Modules import
// const { SageMakerRuntimeClient, InvokeEndpointCommand } = require("@aws-sdk/client-sagemaker-runtime"); // CommonJS import
const client = new SageMakerRuntimeClient(config);
const input = { // InvokeEndpointInput
EndpointName: "STRING_VALUE", // required
Body: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("") // required
ContentType: "STRING_VALUE",
Accept: "STRING_VALUE",
CustomAttributes: "STRING_VALUE",
TargetModel: "STRING_VALUE",
TargetVariant: "STRING_VALUE",
TargetContainerHostname: "STRING_VALUE",
InferenceId: "STRING_VALUE",
EnableExplanations: "STRING_VALUE",
InferenceComponentName: "STRING_VALUE",
SessionId: "STRING_VALUE",
};
const command = new InvokeEndpointCommand(input);
const response = await client.send(command);
// { // InvokeEndpointOutput
// Body: new Uint8Array(), // required
// ContentType: "STRING_VALUE",
// InvokedProductionVariant: "STRING_VALUE",
// CustomAttributes: "STRING_VALUE",
// NewSessionId: "STRING_VALUE",
// ClosedSessionId: "STRING_VALUE",
// };
InvokeEndpointCommand Input
InvokeEndpointCommandInput extends InvokeEndpointCommandInputType
InvokeEndpointCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
InternalDependencyException | server | Your request caused an exception with an internal dependency. Contact customer support. |
InternalFailure | server | An internal failure occurred. |
ModelError | client | Model (owned by the customer in the container) returned 4xx or 5xx error code. |
ModelNotReadyException | client | Either a serverless endpoint variant's resources are still being provisioned, or a multi-model endpoint is still downloading or loading the target model. Wait and try your request again. |
ServiceUnavailable | server | The service is unavailable. Try your call again. |
ValidationError | client | Inspect your request and try again. |
SageMakerRuntimeServiceException | Base exception class for all service exceptions from SageMakerRuntime service. |