Skip to content

create_inference_component async

create_inference_component(
    *,
    config_overrides: Optional[AsyncSageMakerClientConfig] = None,
    inference_component_name: Optional[InferenceComponentName] = None,
    endpoint_name: Optional[EndpointName] = None,
    variant_name: Optional[VariantName] = None,
    specification: Optional[InferenceComponentSpecification] = None,
    specifications: Optional[InferenceComponentSpecificationList] = None,
    runtime_config: Optional[InferenceComponentRuntimeConfig] = None,
    tags: Optional[TagList] = None,
) -> CreateInferenceComponentOutput

Creates an inference component, which is a SageMaker AI hosting object that you can use to deploy a model to an endpoint. In the inference component settings, you specify the model, the endpoint, and how the model utilizes the resources that the endpoint hosts. You can optimize resource utilization by tailoring how the required CPU cores, accelerators, and memory are allocated. You can deploy multiple inference components to an endpoint, where each inference component contains one model and the resource utilization needs for that individual model. After you deploy an inference component, you can directly invoke the associated model when you use the InvokeEndpoint API action.

Parameters:

  • inference_component_name (Optional[InferenceComponentName], default: None ) –

    A unique name to assign to the inference component.

  • endpoint_name (Optional[EndpointName], default: None ) –

    The name of an existing endpoint where you host the inference component.

  • variant_name (Optional[VariantName], default: None ) –

    The name of an existing production variant where you host the inference component.

  • specification (Optional[InferenceComponentSpecification], default: None ) –

    Details about the resources to deploy with this inference component, including the model, container, and compute resources.

  • specifications (Optional[InferenceComponentSpecificationList], default: None ) –

    A list of specification objects for the inference component, one per instance type. Use this parameter when you want to deploy a different model or resource configuration for the inference component on each instance type. You can use either this parameter or the singular Specification parameter, but not both.

  • runtime_config (Optional[InferenceComponentRuntimeConfig], default: None ) –

    Runtime settings for a model that is deployed with an inference component.

  • tags (Optional[TagList], default: None ) –

    A list of key-value pairs associated with the model. For more information, see Tagging Amazon Web Services resources in the Amazon Web Services General Reference.

Raises:

  • 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_component(
    self,
    *,
    config_overrides: Optional[AsyncSageMakerClientConfig] = None,
    inference_component_name: Optional[
        "capo_sagemaker.types.inference_component_name.InferenceComponentName"
    ] = None,
    endpoint_name: Optional[
        "capo_sagemaker.types.endpoint_name.EndpointName"
    ] = None,
    variant_name: Optional["capo_sagemaker.types.variant_name.VariantName"] = None,
    specification: Optional[
        "capo_sagemaker.types.inference_component_specification.InferenceComponentSpecification"
    ] = None,
    specifications: Optional[
        "capo_sagemaker.types.inference_component_specification_list.InferenceComponentSpecificationList"
    ] = None,
    runtime_config: Optional[
        "capo_sagemaker.types.inference_component_runtime_config.InferenceComponentRuntimeConfig"
    ] = None,
    tags: Optional["capo_sagemaker.types.tag_list.TagList"] = None,
) -> "capo_sagemaker.types.create_inference_component_output.CreateInferenceComponentOutput":
    """<p>Creates an inference component, which is a SageMaker AI hosting object that you can use to deploy a model to an endpoint. In the inference component settings, you specify the model, the endpoint, and how the model utilizes the resources that the endpoint hosts. You can optimize resource utilization by tailoring how the required CPU cores, accelerators, and memory are allocated. You can deploy multiple inference components to an endpoint, where each inference component contains one model and the resource utilization needs for that individual model. After you deploy an inference component, you can directly invoke the associated model when you use the InvokeEndpoint API action.</p>

    Args:
        inference_component_name: <p>A unique name to assign to the inference component.</p>
        endpoint_name: <p>The name of an existing endpoint where you host the inference component.</p>
        variant_name: <p>The name of an existing production variant where you host the inference component.</p>
        specification: <p>Details about the resources to deploy with this inference component, including the model, container, and compute resources.</p>
        specifications: <p>A list of specification objects for the inference component, one per instance type. Use this parameter when you want to deploy a different model or resource configuration for the inference component on each instance type. You can use either this parameter or the singular <code>Specification</code> parameter, but not both.</p>
        runtime_config: <p>Runtime settings for a model that is deployed with an inference component.</p>
        tags: <p>A list of key-value pairs associated with the model. For more information, 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.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_component_input.CreateInferenceComponentInput]",
    ) -> AsyncOperationResponse[
        "capo_sagemaker.types.create_inference_component_output.CreateInferenceComponentOutput"
    ]:
        import capo_sagemaker._operations.sage_maker.create_inference_component

        (
            output,
            http_response,
        ) = await capo_sagemaker._operations.sage_maker.create_inference_component.async_create_inference_component(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateInferenceComponent")
    )
    input_: capo_sagemaker.types.create_inference_component_input.CreateInferenceComponentInput = {}
    if inference_component_name is not None:
        input_["inference_component_name"] = inference_component_name
    if endpoint_name is not None:
        input_["endpoint_name"] = endpoint_name
    if variant_name is not None:
        input_["variant_name"] = variant_name
    if specification is not None:
        input_["specification"] = specification
    if specifications is not None:
        input_["specifications"] = specifications
    if runtime_config is not None:
        input_["runtime_config"] = runtime_config
    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