Skip to content

start_async_invoke async

start_async_invoke(
    model_id: AsyncInvokeIdentifier,
    model_input: ModelInputPayload,
    output_data_config: AsyncInvokeOutputDataConfig,
    *,
    config_overrides: Optional[AsyncBedrockRuntimeClientConfig] = None,
    client_request_token: Optional[AsyncInvokeIdempotencyToken] = None,
    tags: Optional[TagList] = None,
) -> StartAsyncInvokeResponse

Starts an asynchronous invocation.

This operation requires permission for the bedrock:InvokeModel action.

To deny all inference access to resources that you specify in the modelId field, you need to deny access to the bedrock:InvokeModel and bedrock:InvokeModelWithResponseStream actions. Doing this also denies access to the resource through the Converse API actions (Converse and ConverseStream). For more information see Deny access for inference on specific models.

Parameters:

Raises:

Source code in docs_src/capo_bedrock_runtime/_services/async_bedrock_runtime.py
async def start_async_invoke(
    self,
    model_id: "capo_bedrock_runtime.types.async_invoke_identifier.AsyncInvokeIdentifier",
    model_input: "capo_bedrock_runtime.types.model_input_payload.ModelInputPayload",
    output_data_config: "capo_bedrock_runtime.types.async_invoke_output_data_config.AsyncInvokeOutputDataConfig",
    *,
    config_overrides: Optional[AsyncBedrockRuntimeClientConfig] = None,
    client_request_token: Optional[
        "capo_bedrock_runtime.types.async_invoke_idempotency_token.AsyncInvokeIdempotencyToken"
    ] = None,
    tags: Optional["capo_bedrock_runtime.types.tag_list.TagList"] = None,
) -> "capo_bedrock_runtime.types.start_async_invoke_response.StartAsyncInvokeResponse":
    """<p>Starts an asynchronous invocation.</p> <p>This operation requires permission for the <code>bedrock:InvokeModel</code> action.</p> <important> <p>To deny all inference access to resources that you specify in the modelId field, you need to deny access to the <code>bedrock:InvokeModel</code> and <code>bedrock:InvokeModelWithResponseStream</code> actions. Doing this also denies access to the resource through the Converse API actions (<a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html">Converse</a> and <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ConverseStream.html">ConverseStream</a>). For more information see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/security_iam_id-based-policy-examples.html#security_iam_id-based-policy-examples-deny-inference">Deny access for inference on specific models</a>. </p> </important>

    Args:
        client_request_token: <p>Specify idempotency token to ensure that requests are not duplicated.</p>
        model_id: <p>The model to invoke.</p>
        model_input: <p>Input to send to the model.</p>
        output_data_config: <p>Where to store the output.</p>
        tags: <p>Tags to apply to the invocation.</p>

    Raises:
        capo_bedrock_runtime.errors.access_denied_exception.AccessDeniedException: <p>The request is denied because you do not have sufficient permissions to perform the requested action. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-access-denied">AccessDeniedException</a> in the Amazon Bedrock User Guide</p>
        capo_bedrock_runtime.errors.conflict_exception.ConflictException: <p>Error occurred because of a conflict while performing an operation.</p>
        capo_bedrock_runtime.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-internal-failure">InternalFailure</a> in the Amazon Bedrock User Guide</p>
        capo_bedrock_runtime.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource ARN was not found. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-resource-not-found">ResourceNotFound</a> in the Amazon Bedrock User Guide</p>
        capo_bedrock_runtime.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>Your request exceeds the service quota for your account. You can view your quotas at <a href="https://docs.aws.amazon.com/servicequotas/latest/userguide/gs-request-quota.html">Viewing service quotas</a>. You can resubmit your request later.</p>
        capo_bedrock_runtime.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service isn't currently available. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-service-unavailable">ServiceUnavailable</a> in the Amazon Bedrock User Guide</p>
        capo_bedrock_runtime.errors.throttling_exception.ThrottlingException: <p>Your request was denied due to exceeding the account quotas for <i>Amazon Bedrock</i>. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-throttling-exception">ThrottlingException</a> in the Amazon Bedrock User Guide</p>
        capo_bedrock_runtime.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by <i>Amazon Bedrock</i>. For troubleshooting this error, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html#ts-validation-error">ValidationError</a> in the Amazon Bedrock User Guide</p>
        capo_bedrock_runtime.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_bedrock_runtime.types.start_async_invoke_request.StartAsyncInvokeRequest]",
    ) -> AsyncOperationResponse[
        "capo_bedrock_runtime.types.start_async_invoke_response.StartAsyncInvokeResponse"
    ]:
        import capo_bedrock_runtime._operations.amazon_bedrock_frontend_service.start_async_invoke

        (
            output,
            http_response,
        ) = await capo_bedrock_runtime._operations.amazon_bedrock_frontend_service.start_async_invoke.async_start_async_invoke(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_bedrock_runtime.types.start_async_invoke_request.StartAsyncInvokeRequest",
    ) -> dict[str, Any]:
        import capo_bedrock_runtime.types.start_async_invoke_request

        return (
            capo_bedrock_runtime.types.start_async_invoke_request.redact_sensitive(
                input_
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("StartAsyncInvoke", redact_input=_redact_input),
    )
    input_: capo_bedrock_runtime.types.start_async_invoke_request.StartAsyncInvokeRequest = {
        "model_id": model_id,
        "model_input": model_input,
        "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 tags is not None:
        input_["tags"] = tags

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