Skip to content

create_model_invocation_job async

create_model_invocation_job(
    job_name: ModelInvocationJobName,
    role_arn: RoleArn,
    model_id: ModelId,
    input_data_config: ModelInvocationJobInputDataConfig,
    output_data_config: ModelInvocationJobOutputDataConfig,
    *,
    config_overrides: Optional[AsyncBedrockClientConfig] = None,
    client_request_token: Optional[ModelInvocationIdempotencyToken] = None,
    vpc_config: Optional[VpcConfig] = None,
    timeout_duration_in_hours: Optional[
        ModelInvocationJobTimeoutDurationInHours
    ] = None,
    tags: Optional[TagList] = None,
    model_invocation_type: Optional[ModelInvocationType] = None,
) -> CreateModelInvocationJobResponse

Creates a batch inference job to invoke a model on multiple prompts. Format your data according to Format your inference data and upload it to an Amazon S3 bucket. For more information, see Process multiple prompts with batch inference.

The response returns a jobArn that you can use to stop or get details about the job.

Parameters:

Raises:

Source code in docs_src/capo_bedrock/_services/async_bedrock.py
async def create_model_invocation_job(
    self,
    job_name: "capo_bedrock.types.model_invocation_job_name.ModelInvocationJobName",
    role_arn: "capo_bedrock.types.role_arn.RoleArn",
    model_id: "capo_bedrock.types.model_id.ModelId",
    input_data_config: "capo_bedrock.types.model_invocation_job_input_data_config.ModelInvocationJobInputDataConfig",
    output_data_config: "capo_bedrock.types.model_invocation_job_output_data_config.ModelInvocationJobOutputDataConfig",
    *,
    config_overrides: Optional[AsyncBedrockClientConfig] = None,
    client_request_token: Optional[
        "capo_bedrock.types.model_invocation_idempotency_token.ModelInvocationIdempotencyToken"
    ] = None,
    vpc_config: Optional["capo_bedrock.types.vpc_config.VpcConfig"] = None,
    timeout_duration_in_hours: Optional[
        "capo_bedrock.types.model_invocation_job_timeout_duration_in_hours.ModelInvocationJobTimeoutDurationInHours"
    ] = None,
    tags: Optional["capo_bedrock.types.tag_list.TagList"] = None,
    model_invocation_type: Optional[
        "capo_bedrock.types.model_invocation_type.ModelInvocationType"
    ] = None,
) -> "capo_bedrock.types.create_model_invocation_job_response.CreateModelInvocationJobResponse":
    """<p>Creates a batch inference job to invoke a model on multiple prompts. Format your data according to <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference-data">Format your inference data</a> and upload it to an Amazon S3 bucket. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference.html">Process multiple prompts with batch inference</a>.</p> <p>The response returns a <code>jobArn</code> that you can use to stop or get details about the job.</p>

    Args:
        job_name: <p>A name to give the batch inference job.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of the service role with permissions to carry out and manage batch inference. You can use the console to create a default service role or follow the steps at <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/batch-iam-sr.html">Create a service role for batch inference</a>.</p>
        client_request_token: <p>A unique, case-sensitive identifier to ensure that the API request 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/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a>.</p>
        model_id: <p>The unique identifier of the foundation model to use for the batch inference job.</p>
        input_data_config: <p>Details about the location of the input to the batch inference job.</p>
        output_data_config: <p>Details about the location of the output of the batch inference job.</p>
        vpc_config: <p>The configuration of the Virtual Private Cloud (VPC) for the data in the batch inference job. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/batch-vpc">Protect batch inference jobs using a VPC</a>.</p>
        timeout_duration_in_hours: <p>The number of hours after which to force the batch inference job to time out.</p>
        tags: <p>Any tags to associate with the batch inference job. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/tagging.html">Tagging Amazon Bedrock resources</a>.</p>
        model_invocation_type: <p>The invocation endpoint for ModelInvocationJob</p>

    Raises:
        capo_bedrock.errors.access_denied_exception.AccessDeniedException: <p>The request is denied because of missing access permissions.</p>
        capo_bedrock.errors.conflict_exception.ConflictException: <p>Error occurred because of a conflict while performing an operation.</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.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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_bedrock.types.create_model_invocation_job_request.CreateModelInvocationJobRequest]",
    ) -> AsyncOperationResponse[
        "capo_bedrock.types.create_model_invocation_job_response.CreateModelInvocationJobResponse"
    ]:
        import capo_bedrock._operations.amazon_bedrock_control_plane_service.create_model_invocation_job

        (
            output,
            http_response,
        ) = await capo_bedrock._operations.amazon_bedrock_control_plane_service.create_model_invocation_job.async_create_model_invocation_job(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateModelInvocationJob")
    )
    input_: capo_bedrock.types.create_model_invocation_job_request.CreateModelInvocationJobRequest = {
        "job_name": job_name,
        "role_arn": role_arn,
        "model_id": model_id,
        "input_data_config": input_data_config,
        "output_data_config": output_data_config,
    }
    if client_request_token is None:
        client_request_token = str(uuid.uuid4())
    input_["client_request_token"] = client_request_token
    if vpc_config is not None:
        input_["vpc_config"] = vpc_config
    if timeout_duration_in_hours is not None:
        input_["timeout_duration_in_hours"] = timeout_duration_in_hours
    if tags is not None:
        input_["tags"] = tags
    if model_invocation_type is not None:
        input_["model_invocation_type"] = model_invocation_type

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output