SageMakerInferenceRouterRuntime / Client / invoke_inference_router_async
invoke_inference_router_async¶
- SageMakerInferenceRouterRuntime.Client.invoke_inference_router_async(**kwargs)¶
Submits an asynchronous inference request to an inference router. Before you call this operation, upload the input data to Amazon S3 in the router’s Amazon Web Services Region. The router returns as soon as it accepts the request, and sends the request to one of the destinations of the routing target. The destination reads the input from Amazon S3, and the inference response is written to the Amazon S3 output path that the routing target specifies.
If a destination doesn’t start the request within the routing target’s
MaxTimeInBacklogSeconds, the router moves the request to another destination. After your model starts processing the request, the request doesn’t move. If no destination can take the request beforeRequestTTLSecondsruns out, or every destination has been tried, the router writes a failure object to theFailureLocationand publishes a notification to the routing target’s error topic, if one is configured.For information about the permissions that the caller and each destination need, see Send asynchronous requests through an inference router.
See also: AWS API Documentation
Request Syntax
response = client.invoke_inference_router_async( InferenceRouterName='string', RoutingTargetName='string', ContentType='string', Accept='string', CustomAttributes='string', InferenceId='string', InputLocation='string', S3OutputPathExtension='string', Filename='string', RequestTTLSeconds=123, InvocationTimeoutSeconds=123 )
- Parameters:
InferenceRouterName (string) –
[REQUIRED]
The name of the inference router to invoke.
RoutingTargetName (string) –
[REQUIRED]
The name of the routing target in the inference router. The routing target must be configured for asynchronous inference.
ContentType (string) – The MIME type of the input data in Amazon S3. The router passes it to the destination.
Accept (string) – The MIME type that you want for the inference response. The router passes it to the destination.
CustomAttributes (string) – Provides additional information about the inference request. The value is an opaque string that the router passes, unchanged, to the model container of the destination that serves the request. The value can contain up to 1,024 visible US-ASCII characters.
InferenceId (string) – An identifier for the inference request. If you don’t provide one, SageMaker AI generates one and returns it in the response.
InputLocation (string) –
[REQUIRED]
The Amazon S3 URI of the object that contains the input data for the inference. The bucket must be in the inference router’s Amazon Web Services Region and owned by the router’s account. The destination endpoint’s execution role reads the object, and the destination’s asynchronous inference limits apply to it.
S3OutputPathExtension (string) – The path extension that is appended to the routing target’s Amazon S3 output path where the inference response is stored.
Filename (string) – The file name of the inference response stored in Amazon S3. If you don’t provide one, SageMaker AI generates one.
RequestTTLSeconds (integer) – The time to live of the request, in seconds, measured from when the router accepts it. If no destination starts the request in this time, the request fails. The default is 21,600 seconds (6 hours).
InvocationTimeoutSeconds (integer) – The maximum time, in seconds, that a destination can spend processing the request before the request is marked as expired. The default is 900 seconds (15 minutes).
- Return type:
dict
- Returns:
Response Syntax
{ 'InferenceId': 'string', 'OutputLocation': 'string', 'FailureLocation': 'string' }
Response Structure
(dict) –
InferenceId (string) –
The identifier for the inference request. This is the
InferenceIdthat you provided, or the one that SageMaker AI generated.OutputLocation (string) –
The Amazon S3 URI where the inference response is written. The location doesn’t change if the router moves the request to another destination.
FailureLocation (string) –
The Amazon S3 URI where the failure details are written if the inference fails.
Exceptions
SageMakerInferenceRouterRuntime.Client.exceptions.ValidationExceptionSageMakerInferenceRouterRuntime.Client.exceptions.AccessDeniedExceptionSageMakerInferenceRouterRuntime.Client.exceptions.ServiceUnavailableExceptionSageMakerInferenceRouterRuntime.Client.exceptions.ThrottlingExceptionSageMakerInferenceRouterRuntime.Client.exceptions.RequestTimeoutExceptionSageMakerInferenceRouterRuntime.Client.exceptions.InternalFailure