Deploys a custom model for on-demand inference in Amazon Bedrock. After you deploy your custom model, you use the deployment's Amazon Resource Name (ARN) as the modelId parameter when you submit prompts and generate responses with model inference.
For more information about setting up on-demand inference for custom models, see Set up inference for a custom model.
The following actions are related to the CreateCustomModelDeployment operation:
Parameters:
-
model_deployment_name
(ModelDeploymentName)
–
The name for the custom model deployment. The name must be unique within your Amazon Web Services account and Region.
-
model_arn
(CustomModelArn)
–
The Amazon Resource Name (ARN) of the custom model to deploy for on-demand inference. The custom model must be in the Active state.
-
description
(Optional[CustomModelDeploymentDescription], default:
None
)
–
A description for the custom model deployment to help you identify its purpose.
-
tags
(Optional[TagList], default:
None
)
–
Tags to assign to the custom model deployment. You can use tags to organize and track your Amazon Web Services resources for cost allocation and management purposes.
-
client_request_token
(Optional[IdempotencyToken], default:
None
)
–
A unique, case-sensitive identifier to ensure that the operation completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see Ensuring idempotency.
Raises:
-
AccessDeniedException
–
The request is denied because of missing access permissions.
-
InternalServerException
–
An internal server error occurred. Retry your request.
-
ResourceNotFoundException
–
The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
-
ServiceQuotaExceededException
–
The number of requests exceeds the service quota. Resubmit your request later.
-
ThrottlingException
–
The number of requests exceeds the limit. Resubmit your request later.
-
TooManyTagsException
–
The request contains more tags than can be associated with a resource (50 tags per resource). The maximum number of tags includes both existing tags and those included in your current request.
-
ValidationException
–
Input validation failed. Check your request parameters and retry the request.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_bedrock/_services/bedrock.py
| def create_custom_model_deployment(
self,
model_deployment_name: "capo_bedrock.types.model_deployment_name.ModelDeploymentName",
model_arn: "capo_bedrock.types.custom_model_arn.CustomModelArn",
*,
config_overrides: Optional[BedrockClientConfig] = None,
description: Optional[
"capo_bedrock.types.custom_model_deployment_description.CustomModelDeploymentDescription"
] = None,
tags: Optional["capo_bedrock.types.tag_list.TagList"] = None,
client_request_token: Optional[
"capo_bedrock.types.idempotency_token.IdempotencyToken"
] = None,
) -> "capo_bedrock.types.create_custom_model_deployment_response.CreateCustomModelDeploymentResponse":
"""<p>Deploys a custom model for on-demand inference in Amazon Bedrock. After you deploy your custom model, you use the deployment's Amazon Resource Name (ARN) as the <code>modelId</code> parameter when you submit prompts and generate responses with model inference.</p> <p> For more information about setting up on-demand inference for custom models, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-use.html">Set up inference for a custom model</a>. </p> <p>The following actions are related to the <code>CreateCustomModelDeployment</code> operation:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GetCustomModelDeployment.html">GetCustomModelDeployment</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_ListCustomModelDeployments.html">ListCustomModelDeployments</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_DeleteCustomModelDeployment.html">DeleteCustomModelDeployment</a> </p> </li> </ul>
Args:
model_deployment_name: <p>The name for the custom model deployment. The name must be unique within your Amazon Web Services account and Region.</p>
model_arn: <p>The Amazon Resource Name (ARN) of the custom model to deploy for on-demand inference. The custom model must be in the <code>Active</code> state.</p>
description: <p>A description for the custom model deployment to help you identify its purpose.</p>
tags: <p>Tags to assign to the custom model deployment. You can use tags to organize and track your Amazon Web Services resources for cost allocation and management purposes.</p>
client_request_token: <p>A unique, case-sensitive identifier to ensure that the operation completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-idempotency.html">Ensuring idempotency</a>.</p>
Raises:
capo_bedrock.errors.access_denied_exception.AccessDeniedException: <p>The request is denied because of missing access permissions.</p>
capo_bedrock.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry your request.</p>
capo_bedrock.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.</p>
capo_bedrock.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The number of requests exceeds the service quota. Resubmit your request later.</p>
capo_bedrock.errors.throttling_exception.ThrottlingException: <p>The number of requests exceeds the limit. Resubmit your request later.</p>
capo_bedrock.errors.too_many_tags_exception.TooManyTagsException: <p>The request contains more tags than can be associated with a resource (50 tags per resource). The maximum number of tags includes both existing tags and those included in your current request. </p>
capo_bedrock.errors.validation_exception.ValidationException: <p>Input validation failed. Check your request parameters and retry the request.</p>
capo_bedrock.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_bedrock.types.create_custom_model_deployment_request.CreateCustomModelDeploymentRequest]",
) -> OperationResponse[
"capo_bedrock.types.create_custom_model_deployment_response.CreateCustomModelDeploymentResponse"
]:
import capo_bedrock._operations.amazon_bedrock_control_plane_service.create_custom_model_deployment
output, http_response = (
capo_bedrock._operations.amazon_bedrock_control_plane_service.create_custom_model_deployment.create_custom_model_deployment(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreateCustomModelDeployment")
)
input_: capo_bedrock.types.create_custom_model_deployment_request.CreateCustomModelDeploymentRequest = {
"model_deployment_name": model_deployment_name,
"model_arn": model_arn,
}
if description is not None:
input_["description"] = description
if tags is not None:
input_["tags"] = tags
if client_request_token is None:
client_request_token = str(uuid.uuid4())
input_["client_request_token"] = client_request_token
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|