Skip to content

list_custom_models

list_custom_models(
    *,
    config_overrides: Optional[BedrockClientConfig] = None,
    creation_time_before: Optional[Timestamp] = None,
    creation_time_after: Optional[Timestamp] = None,
    name_contains: Optional[CustomModelName] = None,
    base_model_arn_equals: Optional[ModelArn] = None,
    foundation_model_arn_equals: Optional[FoundationModelArn] = None,
    max_results: Optional[MaxResults] = None,
    next_token: Optional[PaginationToken] = None,
    sort_by: Optional[SortModelsBy] = None,
    sort_order: Optional[SortOrder] = None,
    is_owned: Optional[bool] = None,
    model_status: Optional[ModelStatus] = None,
) -> ListCustomModelsResponse

Returns a list of the custom models that you have created with the CreateModelCustomizationJob operation.

For more information, see Custom models in the Amazon Bedrock User Guide.

Parameters:

  • creation_time_before (Optional[Timestamp], default: None ) –

    Return custom models created before the specified time.

  • creation_time_after (Optional[Timestamp], default: None ) –

    Return custom models created after the specified time.

  • name_contains (Optional[CustomModelName], default: None ) –

    Return custom models only if the job name contains these characters.

  • base_model_arn_equals (Optional[ModelArn], default: None ) –

    Return custom models only if the base model Amazon Resource Name (ARN) matches this parameter.

  • foundation_model_arn_equals (Optional[FoundationModelArn], default: None ) –

    Return custom models only if the foundation model Amazon Resource Name (ARN) matches this parameter.

  • max_results (Optional[MaxResults], default: None ) –

    The maximum number of results to return in the response. If the total number of results is greater than this value, use the token returned in the response in the nextToken field when making another request to return the next batch of results.

  • next_token (Optional[PaginationToken], default: None ) –

    If the total number of results is greater than the maxResults value provided in the request, enter the token returned in the nextToken field in the response in this field to return the next batch of results.

  • sort_by (Optional[SortModelsBy], default: None ) –

    The field to sort by in the returned list of models.

  • sort_order (Optional[SortOrder], default: None ) –

    The sort order of the results.

  • is_owned (Optional[bool], default: None ) –

    Return custom models depending on if the current account owns them (true) or if they were shared with the current account (false).

  • model_status (Optional[ModelStatus], default: None ) –

    The status of them model to filter results by. Possible values include:

    • Creating - Include only models that are currently being created and validated.

    • Active - Include only models that have been successfully created and are ready for use.

    • Failed - Include only models where the creation process failed.

    If you don't specify a status, the API returns models in all states.

Raises:

Source code in docs_src/capo_bedrock/_services/bedrock.py
def list_custom_models(
    self,
    *,
    config_overrides: Optional[BedrockClientConfig] = None,
    creation_time_before: Optional["capo_bedrock.types.timestamp.Timestamp"] = None,
    creation_time_after: Optional["capo_bedrock.types.timestamp.Timestamp"] = None,
    name_contains: Optional[
        "capo_bedrock.types.custom_model_name.CustomModelName"
    ] = None,
    base_model_arn_equals: Optional["capo_bedrock.types.model_arn.ModelArn"] = None,
    foundation_model_arn_equals: Optional[
        "capo_bedrock.types.foundation_model_arn.FoundationModelArn"
    ] = None,
    max_results: Optional["capo_bedrock.types.max_results.MaxResults"] = None,
    next_token: Optional[
        "capo_bedrock.types.pagination_token.PaginationToken"
    ] = None,
    sort_by: Optional["capo_bedrock.types.sort_models_by.SortModelsBy"] = None,
    sort_order: Optional["capo_bedrock.types.sort_order.SortOrder"] = None,
    is_owned: Optional[bool] = None,
    model_status: Optional["capo_bedrock.types.model_status.ModelStatus"] = None,
) -> "capo_bedrock.types.list_custom_models_response.ListCustomModelsResponse":
    """<p>Returns a list of the custom models that you have created with the <code>CreateModelCustomizationJob</code> operation.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/custom-models.html">Custom models</a> in the <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-service.html">Amazon Bedrock User Guide</a>.</p>

    Args:
        creation_time_before: <p>Return custom models created before the specified time. </p>
        creation_time_after: <p>Return custom models created after the specified time. </p>
        name_contains: <p>Return custom models only if the job name contains these characters.</p>
        base_model_arn_equals: <p>Return custom models only if the base model Amazon Resource Name (ARN) matches this parameter.</p>
        foundation_model_arn_equals: <p>Return custom models only if the foundation model Amazon Resource Name (ARN) matches this parameter.</p>
        max_results: <p>The maximum number of results to return in the response. If the total number of results is greater than this value, use the token returned in the response in the <code>nextToken</code> field when making another request to return the next batch of results.</p>
        next_token: <p>If the total number of results is greater than the <code>maxResults</code> value provided in the request, enter the token returned in the <code>nextToken</code> field in the response in this field to return the next batch of results.</p>
        sort_by: <p>The field to sort by in the returned list of models.</p>
        sort_order: <p>The sort order of the results.</p>
        is_owned: <p>Return custom models depending on if the current account owns them (<code>true</code>) or if they were shared with the current account (<code>false</code>).</p>
        model_status: <p>The status of them model to filter results by. Possible values include:</p> <ul> <li> <p> <code>Creating</code> - Include only models that are currently being created and validated.</p> </li> <li> <p> <code>Active</code> - Include only models that have been successfully created and are ready for use.</p> </li> <li> <p> <code>Failed</code> - Include only models where the creation process failed.</p> </li> </ul> <p>If you don't specify a status, the API returns models in all states.</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.throttling_exception.ThrottlingException: <p>The number of requests exceeds the limit. Resubmit your request later.</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.list_custom_models_request.ListCustomModelsRequest]",
    ) -> OperationResponse[
        "capo_bedrock.types.list_custom_models_response.ListCustomModelsResponse"
    ]:
        import capo_bedrock._operations.amazon_bedrock_control_plane_service.list_custom_models

        output, http_response = (
            capo_bedrock._operations.amazon_bedrock_control_plane_service.list_custom_models.list_custom_models(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListCustomModels")
    )
    input_: capo_bedrock.types.list_custom_models_request.ListCustomModelsRequest = {}
    if creation_time_before is not None:
        input_["creation_time_before"] = creation_time_before
    if creation_time_after is not None:
        input_["creation_time_after"] = creation_time_after
    if name_contains is not None:
        input_["name_contains"] = name_contains
    if base_model_arn_equals is not None:
        input_["base_model_arn_equals"] = base_model_arn_equals
    if foundation_model_arn_equals is not None:
        input_["foundation_model_arn_equals"] = foundation_model_arn_equals
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if sort_by is not None:
        input_["sort_by"] = sort_by
    if sort_order is not None:
        input_["sort_order"] = sort_order
    if is_owned is not None:
        input_["is_owned"] = is_owned
    if model_status is not None:
        input_["model_status"] = model_status

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