createEndpointConfig method

Future<CreateEndpointConfigOutput> createEndpointConfig({
  1. required String endpointConfigName,
  2. required List<ProductionVariant> productionVariants,
  3. AsyncInferenceConfig? asyncInferenceConfig,
  4. DataCaptureConfig? dataCaptureConfig,
  5. bool? enableNetworkIsolation,
  6. String? executionRoleArn,
  7. ExplainerConfig? explainerConfig,
  8. String? kmsKeyId,
  9. MetricsConfig? metricsConfig,
  10. List<ProductionVariant>? shadowProductionVariants,
  11. List<Tag>? tags,
  12. VpcConfig? vpcConfig,
})

Creates an endpoint configuration that SageMaker hosting services uses to deploy models. In the configuration, you identify one or more models, created using the CreateModel API, to deploy and the resources that you want SageMaker to provision. Then you call the CreateEndpoint API. In the request, you define a ProductionVariant, for each model that you want to deploy. Each ProductionVariant parameter also describes the resources that you want SageMaker to provision. This includes the number and type of ML compute instances to deploy.

If you are hosting multiple models, you also assign a VariantWeight to specify how much traffic you want to allocate to each model. For example, suppose that you want to host two models, A and B, and you assign traffic weight 2 for model A and 1 for model B. SageMaker distributes two-thirds of the traffic to Model A, and one-third to model B.

May throw ResourceLimitExceeded.

Parameter endpointConfigName : The name of the endpoint configuration. You specify this name in a CreateEndpoint request.

Parameter productionVariants : An array of ProductionVariant objects, one for each model that you want to host at this endpoint.

Parameter asyncInferenceConfig : Specifies configuration for how an endpoint performs asynchronous inference. This is a required field in order for your Endpoint to be invoked using InvokeEndpointAsync.

Parameter enableNetworkIsolation : Sets whether all model containers deployed to the endpoint are isolated. If they are, no inbound or outbound network calls can be made to or from the model containers.

Parameter executionRoleArn : The Amazon Resource Name (ARN) of an IAM role that Amazon SageMaker AI can assume to perform actions on your behalf. For more information, see SageMaker AI Roles.

Parameter explainerConfig : A member of CreateEndpointConfig that enables explainers.

Parameter kmsKeyId : The Amazon Resource Name (ARN) of a Amazon Web Services Key Management Service key that SageMaker uses to encrypt data on the storage volume attached to the ML compute instance that hosts the endpoint.

The KmsKeyId can be any of the following formats:

  • Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
  • Key ARN: arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
  • Alias name: alias/ExampleAlias
  • Alias name ARN: arn:aws:kms:us-west-2:111122223333:alias/ExampleAlias
The KMS key policy must grant permission to the IAM role that you specify in your CreateEndpoint, UpdateEndpoint requests. For more information, refer to the Amazon Web Services Key Management Service section Using Key Policies in Amazon Web Services KMS

Implementation

Future<CreateEndpointConfigOutput> createEndpointConfig({
  required String endpointConfigName,
  required List<ProductionVariant> productionVariants,
  AsyncInferenceConfig? asyncInferenceConfig,
  DataCaptureConfig? dataCaptureConfig,
  bool? enableNetworkIsolation,
  String? executionRoleArn,
  ExplainerConfig? explainerConfig,
  String? kmsKeyId,
  MetricsConfig? metricsConfig,
  List<ProductionVariant>? shadowProductionVariants,
  List<Tag>? tags,
  VpcConfig? vpcConfig,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'SageMaker.CreateEndpointConfig'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'EndpointConfigName': endpointConfigName,
      'ProductionVariants': productionVariants,
      if (asyncInferenceConfig != null)
        'AsyncInferenceConfig': asyncInferenceConfig,
      if (dataCaptureConfig != null) 'DataCaptureConfig': dataCaptureConfig,
      if (enableNetworkIsolation != null)
        'EnableNetworkIsolation': enableNetworkIsolation,
      if (executionRoleArn != null) 'ExecutionRoleArn': executionRoleArn,
      if (explainerConfig != null) 'ExplainerConfig': explainerConfig,
      if (kmsKeyId != null) 'KmsKeyId': kmsKeyId,
      if (metricsConfig != null) 'MetricsConfig': metricsConfig,
      if (shadowProductionVariants != null)
        'ShadowProductionVariants': shadowProductionVariants,
      if (tags != null) 'Tags': tags,
      if (vpcConfig != null) 'VpcConfig': vpcConfig,
    },
  );

  return CreateEndpointConfigOutput.fromJson(jsonResponse.body);
}