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 Creating until 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 allow sagemaker: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 the RoutingStatus of each destination.
To invoke the router, use InvokeInferenceRouter or InvokeInferenceRouterAsync. For information about inference routers, see Route requests across Regions with inference routers.
Parameters:
-
inference_router_name
(Optional[InferenceRouterName], default:
None
)
–
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.
-
routing_targets
(Optional[RoutingTargetList], default:
None
)
–
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.
-
client_token
(Optional[InferenceRouterClientToken], default:
None
)
–
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.
-
tags
(Optional[TagList], default:
None
)
–
Raises:
-
ConflictException
–
There was a conflict when you attempted to modify a SageMaker entity such as an Experiment or Artifact.
-
ResourceAlreadyExists
–
The resource that you are trying to create already exists. Use a different resource name, or delete the existing resource before retrying.
-
ResourceLimitExceeded
–
You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_sagemaker/_services/async_sage_maker.py
| async def create_inference_router(
self,
*,
config_overrides: Optional[AsyncSageMakerClientConfig] = None,
inference_router_name: Optional[
"capo_sagemaker.types.inference_router_name.InferenceRouterName"
] = None,
routing_targets: Optional[
"capo_sagemaker.types.routing_target_list.RoutingTargetList"
] = None,
client_token: Optional[
"capo_sagemaker.types.inference_router_client_token.InferenceRouterClientToken"
] = None,
tags: Optional["capo_sagemaker.types.tag_list.TagList"] = None,
) -> "capo_sagemaker.types.create_inference_router_output.CreateInferenceRouterOutput":
"""<p>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.</p> <p>The router's status is <code>Creating</code> until 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 allow <code>sagemaker:DescribeEndpoint</code>. 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 <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeInferenceRouter.html">DescribeInferenceRouter</a> and see the <code>RoutingStatus</code> of each destination.</p> <p>To invoke the router, use <code>InvokeInferenceRouter</code> or <code>InvokeInferenceRouterAsync</code>. For information about inference routers, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/inference-router.html">Route requests across Regions with inference routers</a>.</p>
Args:
inference_router_name: <p>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.</p>
routing_targets: <p>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.</p>
client_token: <p>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.</p>
tags: <p>A list of key-value pairs to apply to the inference router. For information about tagging, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html">Tagging Amazon Web Services resources</a> in the <i>Amazon Web Services General Reference</i>.</p>
Raises:
capo_sagemaker.errors.conflict_exception.ConflictException: <p>There was a conflict when you attempted to modify a SageMaker entity such as an <code>Experiment</code> or <code>Artifact</code>.</p>
capo_sagemaker.errors.resource_already_exists.ResourceAlreadyExists: <p>The resource that you are trying to create already exists. Use a different resource name, or delete the existing resource before retrying.</p>
capo_sagemaker.errors.resource_limit_exceeded.ResourceLimitExceeded: <p> You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created. </p>
capo_sagemaker.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_sagemaker.types.create_inference_router_input.CreateInferenceRouterInput]",
) -> AsyncOperationResponse[
"capo_sagemaker.types.create_inference_router_output.CreateInferenceRouterOutput"
]:
import capo_sagemaker._operations.sage_maker.create_inference_router
(
output,
http_response,
) = await capo_sagemaker._operations.sage_maker.create_inference_router.async_create_inference_router(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreateInferenceRouter")
)
input_: capo_sagemaker.types.create_inference_router_input.CreateInferenceRouterInput = {}
if inference_router_name is not None:
input_["inference_router_name"] = inference_router_name
if routing_targets is not None:
input_["routing_targets"] = routing_targets
if client_token is None:
client_token = str(uuid.uuid4())
input_["client_token"] = client_token
if tags is not None:
input_["tags"] = tags
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|