SageMaker / Client / create_inference_router
create_inference_router¶
- SageMaker.Client.create_inference_router(**kwargs)¶
Creates an inference router. An inference router is a Regional SageMaker AI resource that sends each inference request to one of the endpoints or inference components that you list for a routing target. These destinations can be in any Amazon Web Services account, and in any Amazon Web Services Region in the same partition as the router.
The router’s status is
Creatinguntil it’s ready to use. SageMaker AI checks that each endpoint is a real-time or asynchronous endpoint, as the routing target requires, and rejects one of the wrong type. It checks endpoints in other accounts with your credentials, so the endpoint policy must allowsagemaker:DescribeEndpoint. SageMaker AI accepts an endpoint that it can’t check, for example one that doesn’t exist. Requests to it fail if it’s the wrong type or doesn’t exist. To see the status of each destination, call DescribeInferenceRouter and see theRoutingStatusof each destination.To invoke the router, use
InvokeInferenceRouterorInvokeInferenceRouterAsync. For information about inference routers, see Route requests across Regions with inference routers.See also: AWS API Documentation
Request Syntax
response = client.create_inference_router( InferenceRouterName='string', RoutingTargets=[ { 'Name': 'string', 'Destinations': [ { 'ResourceArn': 'string', 'RoutingStatus': 'Routable'|'Unroutable'|'Unknown' }, ], 'AsyncInferenceConfig': { 'OutputConfig': { 'S3OutputPath': 'string', 'S3FailurePath': 'string', 'KmsKeyId': 'string', 'NotificationConfig': { 'SuccessTopic': 'string', 'ErrorTopic': 'string' } }, 'ClientConfig': { 'MaxTimeInBacklogSeconds': 123 } }, 'RoutingPreference': 'LocalRegionFirst'|'InstancePoolOrder' }, ], ClientToken='string', Tags=[ { 'Key': 'string', 'Value': 'string' }, ] )
- Parameters:
InferenceRouterName (string) –
[REQUIRED]
The name of the inference router. The name must be unique within your account in the current Amazon Web Services Region. The name is case sensitive.
RoutingTargets (list) –
[REQUIRED]
The routing targets of the inference router. Each routing target is a model that callers name when they invoke the router, and the destinations that serve it.
(dict) –
A model that an inference router serves, and the destinations that can serve it. When you invoke the router, you name the routing target, and the router sends the request to one of its destinations.
Every destination in a routing target must serve the same model, with the same request and response format.
Name (string) – [REQUIRED]
The name of the routing target. Callers specify this name in the
RoutingTargetNameparameter when they invoke the inference router. The name must be unique within the router.Destinations (list) – [REQUIRED]
The endpoints and inference components that serve the routing target. Each destination can appear only once in a routing target.
In an asynchronous routing target, every destination must be an asynchronous inference endpoint. In a real-time routing target, no destination can be one. SageMaker AI checks an endpoint in another account with your credentials, so both your IAM policy and the endpoint policy must allow
sagemaker:DescribeEndpoint. If an endpoint can’t be checked, for example because it isn’t found or can’t be read in time, it’s accepted, and requests to it fail if it’s the wrong mode.(dict) –
An endpoint or inference component that serves a routing target.
ResourceArn (string) – [REQUIRED]
The Amazon Resource Name (ARN) of the endpoint or inference component. The destination can be in any account, and in any Amazon Web Services Region in the same partition as the inference router. To use a destination in another account, its owner must allow your account to invoke it through your router, in an endpoint policy.
RoutingStatus (string) –
Whether the inference router can send requests to the destination, as checked when you called
DescribeInferenceRouter. This value isn’t the destination’s own status. SageMaker AI ignores this field inCreateInferenceRouterandUpdateInferenceRouterrequests.Routable
The destination is serving and the router can send it requests. A routable destination can still be overloaded.
Unroutable
The destination can’t serve requests. For example, it’s being created or has failed, or it has no capacity and no way to get any. A destination in your account that doesn’t exist is also
Unroutable.Unknown
SageMaker AI couldn’t check the destination, for example because you aren’t allowed to describe it or the check timed out. The destination might still be serving.
AsyncInferenceConfig (dict) –
The asynchronous inference settings of the routing target. Specify this setting to make the routing target asynchronous. If you omit it, the routing target serves real-time requests.
Asynchronous routing targets aren’t available in all Amazon Web Services Regions. For information about asynchronous routing targets and Region availability, see Send asynchronous requests through an inference router.
Because
UpdateInferenceRouterreplaces all routing targets, include this setting in every update of an asynchronous routing target.For information about asynchronous routing targets, see Send asynchronous requests through an inference router.
OutputConfig (dict) – [REQUIRED]
The Amazon S3 locations for the results of asynchronous requests, and the notification settings.
S3OutputPath (string) – [REQUIRED]
The Amazon S3 location for the results of successful requests. The bucket must be in the inference router’s Amazon Web Services Region and owned by the router’s account.
S3FailurePath (string) – [REQUIRED]
The Amazon S3 location for the failure details of failed requests. The bucket must be in the inference router’s Amazon Web Services Region and owned by the router’s account.
KmsKeyId (string) –
The KMS key that encrypts the results in Amazon S3. You can specify a key ID, key ARN, alias name, or alias ARN. If any destination is in a different account or Amazon Web Services Region from the inference router, specify a key ARN or an alias ARN.
NotificationConfig (dict) –
The Amazon SNS topics that the inference router publishes to when a request completes or fails.
SuccessTopic (string) –
The ARN of the Amazon SNS topic to publish to when a request completes. The topic must be a standard topic, and can be in any Amazon Web Services Region.
ErrorTopic (string) –
The ARN of the Amazon SNS topic to publish to when a request fails, or when the router can’t place it on any destination. The topic must be a standard topic, and can be in any Amazon Web Services Region.
ClientConfig (dict) –
How the inference router submits requests to destinations.
MaxTimeInBacklogSeconds (integer) –
The maximum time, in seconds, that a request can wait at a destination before the inference router moves it to another destination. The default is 900 seconds.
RoutingPreference (string) –
How the inference router chooses among the routing target’s destinations. The default is
LocalRegionFirst.LocalRegionFirst
The router uses destinations in its own Region first. When the request leaves the Region, the router spreads it across healthy destinations in other Regions.
InstancePoolOrder
The router prefers destinations by instance type first and by Region second. Every destination must be an endpoint that lists the same two or more instance types, each with a different priority, in the same priority order. This value is supported only for asynchronous routing targets.
With either value, the router uses destinations whose health or capacity is reduced after the others, but doesn’t exclude them.
ClientToken (string) –
A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you reuse a client token, use the same request parameters. Otherwise, the request fails.
This field is autopopulated if not provided.
Tags (list) –
A list of key-value pairs to apply to the inference router. For information about tagging, see Tagging Amazon Web Services resources in the Amazon Web Services General Reference.
(dict) –
A tag object that consists of a key and an optional value, used to manage metadata for SageMaker Amazon Web Services resources.
You can add tags to notebook instances, training jobs, hyperparameter tuning jobs, batch transform jobs, models, labeling jobs, work teams, endpoint configurations, and endpoints. For more information on adding tags to SageMaker resources, see AddTags.
For more information on adding metadata to your Amazon Web Services resources with tagging, see Tagging Amazon Web Services resources. For advice on best practices for managing Amazon Web Services resources with tagging, see Tagging Best Practices: Implement an Effective Amazon Web Services Resource Tagging Strategy.
Key (string) – [REQUIRED]
The tag key. Tag keys must be unique per resource.
Value (string) – [REQUIRED]
The tag value.
- Return type:
dict
- Returns:
Response Syntax
{ 'InferenceRouterArn': 'string' }
Response Structure
(dict) –
InferenceRouterArn (string) –
The Amazon Resource Name (ARN) of the inference router.
Exceptions
SageMaker.Client.exceptions.ResourceAlreadyExistsSageMaker.Client.exceptions.ConflictExceptionSageMaker.Client.exceptions.ResourceLimitExceeded