Skip to content

create_ai_recommendation_job

create_ai_recommendation_job(
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    ai_recommendation_job_name: Optional[AIEntityName] = None,
    model_source: Optional[AIModelSource] = None,
    output_config: Optional[AIRecommendationOutputConfig] = None,
    ai_workload_config_identifier: Optional[AIResourceIdentifier] = None,
    performance_target: Optional[AIRecommendationPerformanceTarget] = None,
    role_arn: Optional[RoleArn] = None,
    inference_specification: Optional[AIRecommendationInferenceSpecification] = None,
    optimize_model: Optional[AIRecommendationAllowOptimization] = None,
    compute_spec: Optional[AIRecommendationComputeSpec] = None,
    adapter_source: Optional[AIAdapterSource] = None,
    tags: Optional[TagList] = None,
) -> CreateAIRecommendationJobResponse

Creates a recommendation job that generates intelligent optimization recommendations for generative AI inference deployments. The job analyzes your model, workload configuration, and performance targets to recommend optimal instance types, model optimization techniques (such as quantization and speculative decoding), and deployment configurations.

Parameters:

  • ai_recommendation_job_name (Optional[AIEntityName], default: None ) –

    The name of the AI recommendation job. The name must be unique within your Amazon Web Services account in the current Amazon Web Services Region.

  • model_source (Optional[AIModelSource], default: None ) –

    The source of the model to optimize. Specify the Amazon S3 location of the model artifacts.

  • output_config (Optional[AIRecommendationOutputConfig], default: None ) –

    The output configuration for the recommendation job, including the Amazon S3 location for results and an optional model package group where the optimized model is registered.

  • ai_workload_config_identifier (Optional[AIResourceIdentifier], default: None ) –

    The name or Amazon Resource Name (ARN) of the AI workload configuration to use for this recommendation job.

  • performance_target (Optional[AIRecommendationPerformanceTarget], default: None ) –

    The performance targets for the recommendation job. Specify constraints on metrics such as time to first token (ttft-ms), throughput, or cost.

  • role_arn (Optional[RoleArn], default: None ) –

    The Amazon Resource Name (ARN) of an IAM role that enables Amazon SageMaker AI to perform tasks on your behalf.

  • inference_specification (Optional[AIRecommendationInferenceSpecification], default: None ) –

    The inference framework configuration. Specify the framework (such as LMI or vLLM) for the recommendation job.

  • optimize_model (Optional[AIRecommendationAllowOptimization], default: None ) –

    Whether to allow model optimization techniques such as quantization, speculative decoding, and kernel tuning. The default is true.

  • compute_spec (Optional[AIRecommendationComputeSpec], default: None ) –

    The compute resource specification for the recommendation job. You can specify up to 3 instance types to consider, and optionally provide capacity reservation configuration.

  • adapter_source (Optional[AIAdapterSource], default: None ) –

    The LoRA adapter source for the recommendation job. Specify either a list of model package ARNs or Amazon S3 URIs for your LoRA adapters. When this parameter is absent, the recommendation job runs without LoRA adapter support.

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

    The metadata that you apply to Amazon Web Services resources to help you categorize and organize them.

Raises:

Source code in docs_src/capo_sagemaker/_services/sage_maker.py
def create_ai_recommendation_job(
    self,
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    ai_recommendation_job_name: Optional[
        "capo_sagemaker.types.ai_entity_name.AIEntityName"
    ] = None,
    model_source: Optional[
        "capo_sagemaker.types.ai_model_source.AIModelSource"
    ] = None,
    output_config: Optional[
        "capo_sagemaker.types.ai_recommendation_output_config.AIRecommendationOutputConfig"
    ] = None,
    ai_workload_config_identifier: Optional[
        "capo_sagemaker.types.ai_resource_identifier.AIResourceIdentifier"
    ] = None,
    performance_target: Optional[
        "capo_sagemaker.types.ai_recommendation_performance_target.AIRecommendationPerformanceTarget"
    ] = None,
    role_arn: Optional["capo_sagemaker.types.role_arn.RoleArn"] = None,
    inference_specification: Optional[
        "capo_sagemaker.types.ai_recommendation_inference_specification.AIRecommendationInferenceSpecification"
    ] = None,
    optimize_model: Optional[
        "capo_sagemaker.types.ai_recommendation_allow_optimization.AIRecommendationAllowOptimization"
    ] = None,
    compute_spec: Optional[
        "capo_sagemaker.types.ai_recommendation_compute_spec.AIRecommendationComputeSpec"
    ] = None,
    adapter_source: Optional[
        "capo_sagemaker.types.ai_adapter_source.AIAdapterSource"
    ] = None,
    tags: Optional["capo_sagemaker.types.tag_list.TagList"] = None,
) -> "capo_sagemaker.types.create_ai_recommendation_job_response.CreateAIRecommendationJobResponse":
    """<p>Creates a recommendation job that generates intelligent optimization recommendations for generative AI inference deployments. The job analyzes your model, workload configuration, and performance targets to recommend optimal instance types, model optimization techniques (such as quantization and speculative decoding), and deployment configurations.</p>

    Args:
        ai_recommendation_job_name: <p>The name of the AI recommendation job. The name must be unique within your Amazon Web Services account in the current Amazon Web Services Region.</p>
        model_source: <p>The source of the model to optimize. Specify the Amazon S3 location of the model artifacts.</p>
        output_config: <p>The output configuration for the recommendation job, including the Amazon S3 location for results and an optional model package group where the optimized model is registered.</p>
        ai_workload_config_identifier: <p>The name or Amazon Resource Name (ARN) of the AI workload configuration to use for this recommendation job.</p>
        performance_target: <p>The performance targets for the recommendation job. Specify constraints on metrics such as time to first token (<code>ttft-ms</code>), <code>throughput</code>, or <code>cost</code>.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of an IAM role that enables Amazon SageMaker AI to perform tasks on your behalf.</p>
        inference_specification: <p>The inference framework configuration. Specify the framework (such as LMI or vLLM) for the recommendation job.</p>
        optimize_model: <p>Whether to allow model optimization techniques such as quantization, speculative decoding, and kernel tuning. The default is <code>true</code>.</p>
        compute_spec: <p>The compute resource specification for the recommendation job. You can specify up to 3 instance types to consider, and optionally provide capacity reservation configuration.</p>
        adapter_source: <p>The LoRA adapter source for the recommendation job. Specify either a list of model package ARNs or Amazon S3 URIs for your LoRA adapters. When this parameter is absent, the recommendation job runs without LoRA adapter support.</p>
        tags: <p>The metadata that you apply to Amazon Web Services resources to help you categorize and organize them.</p>

    Raises:
        capo_sagemaker.errors.resource_in_use.ResourceInUse: <p>Resource being accessed is in use.</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.resource_not_found.ResourceNotFound: <p>Resource being access is not found.</p>
        capo_sagemaker.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sagemaker.types.create_ai_recommendation_job_request.CreateAIRecommendationJobRequest]",
    ) -> OperationResponse[
        "capo_sagemaker.types.create_ai_recommendation_job_response.CreateAIRecommendationJobResponse"
    ]:
        import capo_sagemaker._operations.sage_maker.create_ai_recommendation_job

        output, http_response = (
            capo_sagemaker._operations.sage_maker.create_ai_recommendation_job.create_ai_recommendation_job(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateAIRecommendationJob")
    )
    input_: capo_sagemaker.types.create_ai_recommendation_job_request.CreateAIRecommendationJobRequest = {}
    if ai_recommendation_job_name is not None:
        input_["ai_recommendation_job_name"] = ai_recommendation_job_name
    if model_source is not None:
        input_["model_source"] = model_source
    if output_config is not None:
        input_["output_config"] = output_config
    if ai_workload_config_identifier is not None:
        input_["ai_workload_config_identifier"] = ai_workload_config_identifier
    if performance_target is not None:
        input_["performance_target"] = performance_target
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if inference_specification is not None:
        input_["inference_specification"] = inference_specification
    if optimize_model is not None:
        input_["optimize_model"] = optimize_model
    if compute_spec is not None:
        input_["compute_spec"] = compute_spec
    if adapter_source is not None:
        input_["adapter_source"] = adapter_source
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output