Skip to content

put_vectors async

put_vectors(
    vectors: PutVectorsInputList,
    *,
    config_overrides: Optional[AsyncS3VectorsClientConfig] = None,
    vector_bucket_name: Optional[VectorBucketName] = None,
    index_name: Optional[IndexName] = None,
    index_arn: Optional[IndexArn] = None,
) -> PutVectorsOutput

Adds one or more vectors to a vector index. To specify the vector index, you can either use both the vector bucket name and the vector index name, or use the vector index Amazon Resource Name (ARN).

For more information about limits, see Limitations and restrictions in the Amazon S3 User Guide.

When inserting vector data into your vector index, you must provide the vector data as float32 (32-bit floating point) values. If you pass higher-precision values to an Amazon Web Services SDK, S3 Vectors converts the values to 32-bit floating point before storing them, and GetVectors, ListVectors, and QueryVectors operations return the float32 values. Different Amazon Web Services SDKs may have different default numeric types, so ensure your vectors are properly formatted as float32 values regardless of which SDK you're using. For example, in Python, use numpy.float32 or explicitly cast your values.

Permissions

You must have the s3vectors:PutVectors permission to use this operation.

Parameters:

  • vector_bucket_name (Optional[VectorBucketName], default: None ) –

    The name of the vector bucket that contains the vector index.

  • index_name (Optional[IndexName], default: None ) –

    The name of the vector index where you want to write vectors.

  • index_arn (Optional[IndexArn], default: None ) –

    The ARN of the vector index where you want to write vectors.

  • vectors (PutVectorsInputList) –

    The vectors to add to a vector index. The number of vectors in a single request must not exceed the resource capacity, otherwise the request will be rejected with the error ServiceUnavailableException with the error message "Currently unable to handle the request".

Raises:

Source code in docs_src/capo_s3vectors/_services/async_s3_vectors.py
async def put_vectors(
    self,
    vectors: "capo_s3vectors.types.put_vectors_input_list.PutVectorsInputList",
    *,
    config_overrides: Optional[AsyncS3VectorsClientConfig] = None,
    vector_bucket_name: Optional[
        "capo_s3vectors.types.vector_bucket_name.VectorBucketName"
    ] = None,
    index_name: Optional["capo_s3vectors.types.index_name.IndexName"] = None,
    index_arn: Optional["capo_s3vectors.types.index_arn.IndexArn"] = None,
) -> "capo_s3vectors.types.put_vectors_output.PutVectorsOutput":
    """<p>Adds one or more vectors to a vector index. To specify the vector index, you can either use both the vector bucket name and the vector index name, or use the vector index Amazon Resource Name (ARN). </p> <p>For more information about limits, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-vectors-limitations.html">Limitations and restrictions</a> in the <i>Amazon S3 User Guide</i>.</p> <note> <p>When inserting vector data into your vector index, you must provide the vector data as <code>float32</code> (32-bit floating point) values. If you pass higher-precision values to an Amazon Web Services SDK, S3 Vectors converts the values to 32-bit floating point before storing them, and <code>GetVectors</code>, <code>ListVectors</code>, and <code>QueryVectors</code> operations return the float32 values. Different Amazon Web Services SDKs may have different default numeric types, so ensure your vectors are properly formatted as <code>float32</code> values regardless of which SDK you're using. For example, in Python, use <code>numpy.float32</code> or explicitly cast your values.</p> </note> <dl> <dt>Permissions</dt> <dd> <p>You must have the <code>s3vectors:PutVectors</code> permission to use this operation. </p> </dd> </dl>

    Args:
        vector_bucket_name: <p>The name of the vector bucket that contains the vector index. </p>
        index_name: <p>The name of the vector index where you want to write vectors. </p>
        index_arn: <p>The ARN of the vector index where you want to write vectors.</p>
        vectors: <p>The vectors to add to a vector index. The number of vectors in a single request must not exceed the resource capacity, otherwise the request will be rejected with the error <code>ServiceUnavailableException</code> with the error message "Currently unable to handle the request".</p>

    Raises:
        capo_s3vectors.errors.access_denied_exception.AccessDeniedException: <p>Access denied.</p>
        capo_s3vectors.errors.internal_server_exception.InternalServerException: <p>The request failed due to an internal server error.</p>
        capo_s3vectors.errors.request_timeout_exception.RequestTimeoutException: <p>The request timed out. Retry your request.</p>
        capo_s3vectors.errors.too_many_requests_exception.TooManyRequestsException: <p>The request was denied due to request throttling.</p>
        capo_s3vectors.errors.validation_exception.ValidationException: <p>The requested action isn't valid.</p>
        capo_s3vectors.errors.kms_disabled_exception.KmsDisabledException: <p>The specified Amazon Web Services KMS key isn't enabled.</p>
        capo_s3vectors.errors.kms_invalid_key_usage_exception.KmsInvalidKeyUsageException: <p>The request was rejected for one of the following reasons: </p> <ul> <li> <p>The <code>KeyUsage</code> value of the KMS key is incompatible with the API operation.</p> </li> <li> <p>The encryption algorithm or signing algorithm specified for the operation is incompatible with the type of key material in the KMS key (<code>KeySpec</code>).</p> </li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/kms/latest/APIReference/API_Encrypt.html#API_Encrypt_Errors">InvalidKeyUsageException</a> in the <i>Amazon Web Services Key Management Service API Reference</i>.</p>
        capo_s3vectors.errors.kms_invalid_state_exception.KmsInvalidStateException: <p>The key state of the KMS key isn't compatible with the operation.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/kms/latest/APIReference/API_Encrypt.html#API_Encrypt_Errors">KMSInvalidStateException</a> in the <i>Amazon Web Services Key Management Service API Reference</i>.</p>
        capo_s3vectors.errors.kms_not_found_exception.KmsNotFoundException: <p>The KMS key can't be found.</p>
        capo_s3vectors.errors.not_found_exception.NotFoundException: <p>The request was rejected because the specified resource can't be found.</p>
        capo_s3vectors.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>Your request exceeds a service quota. </p>
        capo_s3vectors.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is unavailable. Wait briefly and retry your request. If it continues to fail, increase your waiting time between retries.</p>
        capo_s3vectors.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_s3vectors.types.put_vectors_input.PutVectorsInput]",
    ) -> AsyncOperationResponse[
        "capo_s3vectors.types.put_vectors_output.PutVectorsOutput"
    ]:
        import capo_s3vectors._operations.s3_vectors.put_vectors

        (
            output,
            http_response,
        ) = await capo_s3vectors._operations.s3_vectors.put_vectors.async_put_vectors(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutVectors")
    )
    input_: capo_s3vectors.types.put_vectors_input.PutVectorsInput = {
        "vectors": vectors
    }
    if vector_bucket_name is not None:
        input_["vector_bucket_name"] = vector_bucket_name
    if index_name is not None:
        input_["index_name"] = index_name
    if index_arn is not None:
        input_["index_arn"] = index_arn

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