Skip to main content
Vector embeddings turn text, images, and other unstructured data into numerical vectors that you can search by similarity, which is the basis for semantic search and retrieval-augmented generation (RAG). This tutorial shows you how to run a nearest-neighbor similarity search by using LanceDB with Object Storage as a persistent vector store. LanceDB writes tables directly to an Object Storage bucket. Each table contains vector embeddings alongside structured metadata, and there is no separate database server to run or manage. Object Storage exposes an S3-compatible API, so LanceDB connects to it with no additional drivers.

Costs

In this tutorial, Nebius AI Cloud charges for one resource: Object Storage, for the storage that the LanceDB files consume in your bucket.

Prerequisites

  1. Make sure you are in a group that has at least the editor role within your tenant or project; for example, the default editors group. You can check this in the Administration → IAM section of the web console.
  2. Set up Python or Node.js for the LanceDB client that you want to use:

Steps

Create an Object Storage bucket

Create a bucket for the LanceDB data. This tutorial uses the Enhanced Throughput storage class because it’s well suited for streaming embeddings or model weights at scale and for latency-sensitive queries. You can use the Standard storage class instead. For a comparison, see Storage classes in Object Storage.
  1. In the web console, go to Storage → Object Storage.
  2. Click Create resource → Bucket.
  3. Enter a name for the bucket. The name must be unique across the region.
  4. Select the Enhanced storage class.
  5. Click Create bucket.

Create a service account and grant it access to the bucket

LanceDB works with the bucket on behalf of a service account. Create a dedicated service account, put it in its own group, and grant that group access to the bucket:
  1. Create a group for the service account:
    1. In the sidebar, go to Administration → IAM.
    2. Click Create resource → Group.
    3. In the window that opens, enter lancedb-access as the group name and select your project as the scope of the group.
    4. Click Create.
  2. Create a service account and add it to the group:
    1. Click Create resource → Service account.
    2. In the window that opens, enter lancedb-sa as the service account name and select the project.
    3. Click Create and continue.
    4. In the window that opens, find the lancedb-access group by its name or ID and click Add next to it.
    5. Click Close.
  3. Grant the group read and write access to the bucket:
    1. Go to Storage → Object Storage, find the bucket, and copy its ID.
    2. Go to Administration → IAM. On the Groups tab, open the lancedb-access group and switch to the Access permits tab.
    3. Click Manage permits.
    4. In the Resource field, paste the bucket ID and press Enter.
    5. Select the storage.editor role.
    6. Click Save changes.
The storage.editor role lets the service account read and write objects in the bucket.

Create an access key

LanceDB authenticates in Object Storage with an access key of the service account. Create an access key for the lancedb-sa service account that you created:
  1. In the sidebar, go to Administration → IAM.
  2. On the Service accounts tab, open the lancedb-sa service account.
  3. On the Keys tab, click Create access key.
  4. Copy the key ID and the secret key and save them in a secure place. The web console shows the secret key only once.

Install LanceDB

Install the LanceDB client for the language that you use:

Set environment variables

LanceDB reads the access key, the region, and the Object Storage endpoint from environment variables. In the terminal where you run the LanceDB code, set the variables:
The variables contain the following values:
  • AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY: Key ID and secret key of the access key that you created. If you created the access key by using the CLI or Terraform in the same terminal, both variables are already set.
  • AWS_DEFAULT_REGION: The region of your project; for example, eu-north1.
  • AWS_ENDPOINT: Object Storage endpoint in the same region.
If you run the LanceDB code in a Jupyter notebook, such as a notebook in a JupyterLab Devlab, set the variables in a notebook cell with %env instead of export; for example, %env AWS_DEFAULT_REGION=<region_ID>.

Connect LanceDB to Object Storage

Open a script or a Jupyter notebook and connect LanceDB to your bucket. In the code, replace <bucket_name> with the name of the bucket that you created:
LanceDB takes the connection settings from the environment variables. To set them in the code instead, see LanceDB storage configuration.

Create a table and insert vectors

Create a table with a vector column and a metadata column, then insert a few rows. This tutorial uses random vectors to keep the example self-contained.
In a real application, you would generate embeddings by using a model deployed in Serverless AI or a model that runs locally with SentenceTransformers. For a Serverless AI example, see the tutorial on Building a RAG electronics store chatbot.
LanceDB writes the table as Lance files under s3://<bucket_name>/lancedb/documents.lance/. You can verify this in the web console: go to Storage → Object Storage and open your bucket. Query the table for the rows nearest to a query vector:
The output shows the two nearest rows along with their _distance scores. Because the data in this example is random, the distances have no semantic meaning — in a real application, vectors would come from an embedding model and low distances would indicate semantic similarity.

Reconnect to an existing table

LanceDB tables persist in Object Storage. To reopen a table in a later session, set the environment variables again, connect to the bucket, and open the table by its name:

How to delete the created resources

The bucket is a chargeable resource. If you no longer need the data, delete the bucket, so Nebius AI Cloud doesn’t charge for it.

See also


“Jupyter” and the Jupyter logos are trademarks or registered trademarks of LF Charities, used by Nebius B.V. with permission.