How to Create an OpenSearch Vector Database Cluster

Last verified 11 Sep 2026

OpenSearch vector database clusters use the same managed OpenSearch engine as DigitalOcean Managed Databases. OpenSearch includes the k-NN, ML Commons, and Hybrid Search plugins, so you can create vector indexes and run similarity queries after the cluster is active.

Create a Database Cluster Using Automation

You can create a vector database cluster using the DigitalOcean CLI (doctl) or the API.

Create a Database Cluster via CLI

To create a vector database cluster using doctl, you need to provide values for the --engine, --region, and --size flags. Use the doctl databases options engines, doctl databases options regions, and doctl databases options slugs commands, respectively, to get a list of available values.

How to Create a Database Using the DigitalOcean CLI
  1. Install doctl, the official DigitalOcean CLI.

  2. Create a personal access token and save it for use with doctl.

  3. Use the token to grant doctl access to your DigitalOcean account.

    doctl auth init
  4. Finally, run doctl databases create. Basic usage looks like this, but you can read the usage docs for more details:

    doctl databases create <name> [flags]

    The following example creates a database cluster named example-database in the nyc1 region with a single 1 GB node:

    doctl databases create example-database --region nyc1 --size db-s-1vcpu-1gb --num-nodes 1

The --wait flag waits until the cluster is online and prints the connection string.

After the cluster is online, add a trusted source so clients can connect to it:

How to Add a Database Firewall Rule to a Given Database Using the DigitalOcean CLI
  1. Install doctl, the official DigitalOcean CLI.

  2. Create a personal access token and save it for use with doctl.

  3. Use the token to grant doctl access to your DigitalOcean account.

    doctl auth init
  4. Finally, run doctl databases firewalls append. Basic usage looks like this, but you can read the usage docs for more details:

    doctl databases firewalls append <database-cluster-id> --rule <type>:<value> [flags]

    The following example appends a firewall rule to a database cluster with the ID ca9f591d-f38h-5555-a0ef-1c02d1d1e35 that allows any resources with the example-tag to access the database:

    doctl databases firewalls append ca9f591d-f38h-5555-a0ef-1c02d1d1e35 --rule tag:example-tag

To view the cluster’s connection details, use:

How to Retrieve Connection Details for a Database Cluster Using the DigitalOcean CLI
  1. Install doctl, the official DigitalOcean CLI.

  2. Create a personal access token and save it for use with doctl.

  3. Use the token to grant doctl access to your DigitalOcean account.

    doctl auth init
  4. Finally, run doctl databases connection. Basic usage looks like this, but you can read the usage docs for more details:

    doctl databases connection <database-cluster-id> [flags]

    The following example retrieves the connection details for a database cluster with the ID f81d4fae-7dec-11d0-a765-00a0c91e6bf6:

    doctl databases connection f81d4fae-7dec-11d0-a765-00a0c91e6bf6

For the full command reference, see doctl databases.

Create a Database Cluster via API

To create a vector database cluster using the API, you need to provide values for the engine, region, and size fields, which specify the database’s engine, its datacenter, and its configuration, including the number of CPUs, amount of RAM, and disk size. Use the /v2/databases/options endpoint to get a list of available values.

How to Create a Database Using the DigitalOcean API

Create a personal access token and save it for use with the API.

cURL

Send a POST request to https://api.digitalocean.com/v2/databases.

Using cURL:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  -d '{"name": "backend", "engine": "pg", "version": "14", "region": "nyc3", "size": "db-s-2vcpu-4gb", "num_nodes": 2, "storage_size_mib": 61440, "tags": ["production"], "do_settings": {"service_cnames": ["db.example.com", "database.myapp.io"]}}' \
  "https://api.digitalocean.com/v2/databases"

Go

Using Godo, the official DigitalOcean API client for Go:

import (
    "context"
    "os"

    "github.com/digitalocean/godo"
)

func main() {
    token := os.Getenv("DIGITALOCEAN_TOKEN")

    client := godo.NewFromToken(token)
    ctx := context.TODO()

    createRequest := &godo.DatabaseCreateRequest{
        Name:       "backend",
        EngineSlug: "pg",
        Version:    "14",
        Region:     "nyc3",
        SizeSlug:   "db-s-2vcpu-4gb",
        NumNodes:   2,
        StorageSizeMiB : 61440,
        DOSettings: &godo.DOSettings{
            ServiceCnames: []string{"db.example.com", "database.myapp.io"},
        },
    }

    cluster, _, err := client.Databases.Create(ctx, createRequest)
}

Python

Using PyDo, the official DigitalOcean API client for Python:

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

create_req = {
  "name": "backend",
  "engine": "pg",
  "version": "14",
  "region": "nyc3",
  "size": "db-s-2vcpu-4gb",
  "num_nodes": 2,
  "storage_size_mib": 61440,
  "tags": [
    "production"
  ],
  "do_settings": {
    "service_cnames": [
      "db.example.com",
      "database.myapp.io"
    ]
  }
}

create_resp = client.databases.create_cluster(body=create_req)

The response includes the cluster ID, connection details, and a status field. Send a GET request to check the cluster status until it changes from creating to online.

After the cluster is online, add a trusted source so clients can connect to the cluster.

To add a trusted source, use the database firewall endpoint and provide the cluster ID and the trusted source type, such as an IP address, Droplet, Kubernetes cluster, App Platform app, or tag:

How to Update Firewall Rules (Trusted Sources) for a Database Using the DigitalOcean API

Create a personal access token and save it for use with the API.

cURL

Send a PUT request to https://api.digitalocean.com/v2/databases/{database_cluster_uuid}/firewall.

Using cURL:

curl -X PUT \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  -d '{"rules": [{"type": "ip_addr","value": "192.168.1.1"},{"type": "droplet","value": "163973392"},{"type": "k8s","value": "ff2a6c52-5a44-4b63-b99c-0e98e7a63d61"},{"type": "tag","value": "backend"}]}' \
  "https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/firewall"

Go

Using Godo, the official DigitalOcean API client for Go:

import (
    "context"
    "os"

    "github.com/digitalocean/godo"
)

func main() {
    token := os.Getenv("DIGITALOCEAN_TOKEN")

    client := godo.NewFromToken(token)
    ctx := context.TODO()

    req := godo.DatabaseUpdateFirewallRulesRequest{
      Rules: []*godo.DatabaseFirewallRule{
        {
         Type:  "ip_addr",
         Value: "192.168.1.1",
         Description: "a development IP address",
       },
        {
         Type:  "droplet",
         Value: "163973392",
       },
        {
         Type:  "k8s",
         Value: "ff2a6c52-5a44-4b63-b99c-0e98e7a63d61",
        },
      },
    }
    _, err := client.Databases.UpdateFirewallRules(ctx, dbID, &req)
}

Python

Using PyDo, the official DigitalOcean API client for Python:

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "rules": [
    {
      "type": "ip_addr",
      "value": "192.168.1.1",
      "description": "a development IP address",
    },
    {
      "type": "k8s",
      "value": "ff2a6c52-5a44-4b63-b99c-0e98e7a63d61"
    },
    {
      "type": "droplet",
      "value": "163973392"
    },
    {
      "type": "tag",
      "value": "backend"
    }
  ]
}
update_resp = client.databases.update_firewall_rules(database_cluster_uuid="a7a8bas", body=req)

To retrieve the cluster’s connection details, send a GET request:

How to Retrieve an Existing Database Cluster Using the DigitalOcean API

Create a personal access token and save it for use with the API.

cURL

Send a GET request to https://api.digitalocean.com/v2/databases/{database_cluster_uuid}.

Using cURL:

curl -X GET \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  "https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30"

Go

Using Godo, the official DigitalOcean API client for Go:

import (
    "context"
    "os"

    "github.com/digitalocean/godo"
)

func main() {
    token := os.Getenv("DIGITALOCEAN_TOKEN")

    client := godo.NewFromToken(token)
    ctx := context.TODO()

    cluster, _, err := client.Databases.Get(ctx, "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30")
}

Python

Using PyDo, the official DigitalOcean API client for Python:

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

get_resp = client.databases.get_cluster(database_cluster_uuid="a7a89a")

The response includes connection information such as the host, port, username, and password.

For all supported parameters, see the Databases API reference.

Create a Vector Database Cluster Using the Control Panel

To create an OpenSearch vector database cluster, go to the Vector Databases page and click Create Vector Database. Or click Create at the top of any page and choose Vector Database from the Data Services section of the menu.

Choose a Database Engine

On the Create a Vector Database page, in the Choose a database engine section, select OpenSearch. The database engine can’t be changed after creation.

The database engine selection portion of the vector database create page

Choose a Database Configuration

In the Choose a database configuration section, choose a configuration based on your expected vector count, vector dimensions, metadata size, and query load:

  • Basic - Shared CPU: CPU processing power is shared among neighboring Droplets on the same host. Best for low-traffic, testing, or development workloads.

  • General Purpose - Dedicated CPU: Provides the full processing power of a single vCPU at all times. Use for small-to-medium vector workloads that need predictable CPU performance, such as staging or production workloads with moderate query volume.

  • Memory-Optimized - Dedicated CPU: Provides the full processing power of a single vCPU at all times. Use for larger vector datasets, higher-dimensional vectors, or high-query-volume workloads where the HNSW graph needs more memory.

Choose CPU Options

Under CPU options, select an option:

  • Regular (Disk: SSD): Use for standard workloads that don’t require NVMe-backed disk performance.
  • Premium AMD (Disk: NVMe): Use for workloads that benefit from faster local disk performance and higher network throughput. This option is only available for Basic - Shared CPU configurations.
  • Premium Intel (Disk: NVMe): Use for workloads that benefit from faster local disk performance, higher network throughput, and predictable CPU performance.

Changing the CPU option can change the available plan sizes, prices, and datacenter regions.

Select a Plan

Under Select a plan, choose a plan size for the cluster. The plan determines the cluster’s vCPUs, RAM, and minimum storage. Each option shows its combined monthly cost and included resources.

Choose a plan with enough RAM for vector indexes, HNSW graph overhead, JVM heap, operating system cache, and workload growth.

Vector workloads are often memory-bound. OpenSearch stores the HNSW graph in memory outside the JVM heap, so query latency can increase sharply when the graph no longer fits in RAM.

Each vector uses four bytes per dimension. The HNSW graph adds memory for each vector’s graph connections. With up to 16 connections per vector, the graph adds about 128 bytes per vector.

Add a 20-30% safety margin for JVM heap, operating system page cache, metadata, source documents, Lucene segments, and future growth.

If you expect your vector dataset to grow significantly, choose a larger plan before indexing large volumes of data. Resizing later may require reindexing or additional migration work, depending on your index design and workload.

After creation, you can increase your cluster’s compute size (number or size of nodes) at any time.

Choose the Number of Nodes

If you select any of the Dedicated CPU plans, the Number of Nodes selector displays below the Select a plan section. Select 1 Node, 3 Nodes, 6 Nodes, 9 Nodes, or 15 Nodes.

Most Basic - Shared CPU plans support 1 Node or 3 Nodes. The 1 vCPU / 2 GB plans are fixed at 1 Node.

Number of nodes selector with 1 Node selected and options for 3, 6, 9, and 15 nodes.

For specific workloads:

  • Use a single-node cluster for development or small production workloads that don’t require high availability.
  • Use at least three nodes for production workloads that need automated failover. OpenSearch replicates primary shards across nodes to tolerate a node failure without data loss.

Choose a Storage Size

Under Choose a storage size, you can increase storage in 10 GiB increments, up to the maximum in the Storage range (the storage range depends on the selected compute plan). Additional storage costs $0.21 per GiB per month.

Storage must be large enough for source documents, metadata, Lucene segments, OpenSearch system indexes, and future growth.

Choose a storage size section showing 40 GiB selected with cost and supported storage range.

You can increase or decrease storage at any time, but you cannot reduce it below the amount currently in use, or below what’s required for backups and growth.

Enable Storage Autoscaling

Under Autoscale storage, select Enable Storage Autoscaling to automatically increase storage when disk utilization on any node in the cluster reaches the specified threshold. The threshold is based on the worst-performing node in the cluster, not the average across nodes.

Click Customize to set a custom Threshold and Storage Increment. For performance and stability, autoscaling can increase storage only up to the maximum allowed by your current plan.

Autoscale storage section with storage autoscaling enabled and customizable threshold and increment fields.
Note

When autoscaling occurs, the specified storage increment is added to each node in the cluster, not distributed across the cluster. Even when data is uneven across nodes, such as with different partition sizes, each node still receives the same increment. The total added storage is the increment multiplied by the number of nodes.

Autoscaling takes several minutes depending on the cluster size. It runs without downtime and you do not need to take any action. When autoscaling occurs, the system bills the added capacity as additional storage.

Choose a Datacenter Region

The Choose a datacenter region section shows the datacenters where you currently have the most resources, with the number of resources shown to the right as X resources. Hover over this text to see the specific resources in the datacenter.

For best performance, choose a datacenter close to the resources that connect to the cluster. Resources in the same datacenter share a VPC network, which reduces latency and keeps traffic off the public internet. Cross-region latency can increase vector query time.

The datacenter selection portion of the databases create page

Available regions depend on the CPU option and plan you select. For available regions, see Regional Availability.

After creation, you can relocate your cluster to another datacenter.

Finalize and Create

In the Finalize and Create section, enter a unique name for the cluster and select a project to add it to. After creation, you can move the cluster to another project, but its name can’t be changed.

Finalize and create section with database cluster name field and project selector.

Review the monthly and hourly cost for the cluster. When finished, click Create Database Cluster.

Clusters typically take five minutes or more to provision. You can complete important configuration tasks such as restricting inbound connections while you wait.

Add a Trusted Source Using Automation

You can add trusted sources using the DigitalOcean CLI (doctl) or the API.

Add a Trusted Source via CLI

To add a trusted source using doctl, use doctl databases firewalls append with the database cluster ID and the trusted source type and value.

How to Add a Trusted Source Using the DigitalOcean CLI
  1. Install doctl, the official DigitalOcean CLI.

  2. Create a personal access token and save it for use with doctl.

  3. Use the token to grant doctl access to your DigitalOcean account.

    doctl auth init
  4. Finally, run doctl databases firewalls append. Basic usage looks like this, but you can read the usage docs for more details:

    doctl databases firewalls append <database-cluster-id> --rule <type>:<value> [flags]

    The following example appends a firewall rule to a database cluster with the ID ca9f591d-f38h-5555-a0ef-1c02d1d1e35 that allows any resources with the example-tag to access the database:

    doctl databases firewalls append ca9f591d-f38h-5555-a0ef-1c02d1d1e35 --rule tag:example-tag

For list, remove, and other firewall commands, see doctl databases firewalls.

Add a Trusted Source via API

To add a trusted source using the API, send a PUT request to the database firewall endpoint with the cluster ID and the trusted source type and value.

How to Add or Remove a Trusted Source Using the DigitalOcean API

Create a personal access token and save it for use with the API.

cURL

Send a PUT request to https://api.digitalocean.com/v2/databases/{database_cluster_uuid}/firewall.

Using cURL:

curl -X PUT \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  -d '{"rules": [{"type": "ip_addr","value": "192.168.1.1"},{"type": "droplet","value": "163973392"},{"type": "k8s","value": "ff2a6c52-5a44-4b63-b99c-0e98e7a63d61"},{"type": "tag","value": "backend"}]}' \
  "https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/firewall"

Go

Using Godo, the official DigitalOcean API client for Go:

import (
    "context"
    "os"

    "github.com/digitalocean/godo"
)

func main() {
    token := os.Getenv("DIGITALOCEAN_TOKEN")

    client := godo.NewFromToken(token)
    ctx := context.TODO()

    req := godo.DatabaseUpdateFirewallRulesRequest{
      Rules: []*godo.DatabaseFirewallRule{
        {
         Type:  "ip_addr",
         Value: "192.168.1.1",
         Description: "a development IP address",
       },
        {
         Type:  "droplet",
         Value: "163973392",
       },
        {
         Type:  "k8s",
         Value: "ff2a6c52-5a44-4b63-b99c-0e98e7a63d61",
        },
      },
    }
    _, err := client.Databases.UpdateFirewallRules(ctx, dbID, &req)
}

Python

Using PyDo, the official DigitalOcean API client for Python:

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "rules": [
    {
      "type": "ip_addr",
      "value": "192.168.1.1",
      "description": "a development IP address",
    },
    {
      "type": "k8s",
      "value": "ff2a6c52-5a44-4b63-b99c-0e98e7a63d61"
    },
    {
      "type": "droplet",
      "value": "163973392"
    },
    {
      "type": "tag",
      "value": "backend"
    }
  ]
}
update_resp = client.databases.update_firewall_rules(database_cluster_uuid="a7a8bas", body=req)

Make Bulk Updates to Trusted Sources Using Automation

Bulk updates replace the cluster’s full trusted sources list. Use them when you need to add, remove, or replace multiple trusted sources in one operation.

Make Bulk Updates to Trusted Sources via CLI

To make bulk updates using doctl, use doctl databases firewalls replace with the full list of trusted sources you want the cluster to keep.

How to Make Bulk Updates to Trusted Sources Using the DigitalOcean CLI

To add, remove, or replace multiple trusted sources in one doctl command, replace the cluster’s full firewall rule list with doctl databases firewalls replace.

Pass the rules you want to keep using comma-separated type:value entries in the --rules flag. Each entry uses:

  • type: droplet, k8s, ip_addr, tag, or app
  • value: the resource ID, Kubernetes cluster UUID, IP address or CIDR range, tag name, or App identifier, depending on type

The rules you pass to replace become the cluster’s full trusted sources list. Any existing rule you omit is removed. To change the list safely, first list the current rules with doctl databases firewalls list, then run replace with the full set of type:value entries you want to keep. Clusters are limited to 100 firewall rules.

Warning

You currently cannot add IPv6 rules to a database cluster’s trusted sources.

For required flags, examples, and output formats, see doctl databases firewalls replace.

Make Bulk Updates to Trusted Sources via API

To make bulk updates using the API, send a PUT request to the database firewall endpoint with the full list of trusted sources you want the cluster to keep.

How to Make Bulk Updates to Trusted Sources Using the DigitalOcean API

To add, remove, or replace multiple trusted sources in a single operation, send a PUT request to /v2/databases/{database_cluster_uuid}/firewall with a JSON body that contains a rules array.

Each object in rules supports:

  • type (required): droplet, k8s, ip_addr, tag, or app
  • value (required): the resource ID, Kubernetes cluster UUID, IP address or CIDR range, tag name, or App identifier, depending on type
  • description (optional): a short note; this appears as the rule label in the Control Panel

The rules in your request become the cluster’s full firewall rule list. Any existing rule you omit is removed. To change the list safely, first list firewall rules with GET /v2/databases/{database_cluster_uuid}/firewall, edit the returned rules array, then send your updated array with PUT to the same path. A successful update returns 204 No Content. Clusters are limited to 100 firewall rules.

Warning

You currently cannot add IPv6 rules to a database cluster’s trusted sources.

For example payloads, authentication, and required OAuth scopes (database:read to list, database:update to change rules), see Update firewall rules (trusted sources) for a database in the Databases API reference.

Add a Trusted Source Using the Control Panel

Note

In the Control Panel, you can make bulk changes to trusted sources, but each source must be entered manually. To update many rules at once or replace the entire list in a single operation, use the API or CLI to make bulk updates to trusted sources.

To add trusted sources to restrict database access, go to the Databases page and select the cluster you want to add trusted sources to. Click the Network Access tab.

The Network Access page lists any trusted sources already added. An icon next to each trusted source indicates its resource type (for example, Droplet, App Platform app, tag, or Kubernetes cluster).

The Network Access tab for an example cluster, showing trusted sources with resource type icons.

Click Add Trusted Sources. In the Add Trusted Sources window, choose one of the following options:

  • Enter specific IP addresses or CIDR notations: Enter specific IP addresses or a CIDR range. Or click My current IP address to use the Quick Add option, which adds your machine’s current IP address.
The Add Trusted Sources window with the option Enter specific IP addresses or CIDR notations selected, and an example CIDR range shown.
  • Quick select Droplets, Kubernetes clusters, Apps, and tags: Use the search to find a resource, or open the dropdown and select a resource from the list. The dropdown groups resources by type, such as Droplets, Applications, tags, and Kubernetes clusters.
The Add Trusted Sources window with the option Quick select Droplets, Kubernetes clusters, Apps, and tags selected, and the Search or select a resource dropdown menu expanded.

When finished, click Add Trusted Sources.

Warning

You currently cannot add IPv6 rules to a database cluster’s trusted sources.

Copy and Store Connection Details

To copy and store your OpenSearch vector database cluster’s connection details for later use, go to the Control Panel, in the left menu, click DATA SERVICES, click Vector Databases, and then select the cluster you want to view connection details for.

Then, in the Overview tab, in the CONNECTION DETAILS section, copy the connection parameters for Public network, username, password, host, and port, then store them securely for later use.

Connection Details section showing vector database connection parameters and copy options.

Set Environment Variables for a Trusted Source

To set environment variables for a trusted source, open a terminal session using the trusted source you set up:

export OPENSEARCH_HOST="<your-cluster-host>"
export OPENSEARCH_PORT="<your-cluster-port>"
export OPENSEARCH_USER="<your-cluster-username>"
export OPENSEARCH_PASSWORD="<your-cluster-password>"
export OS="https://$OPENSEARCH_USER:$OPENSEARCH_PASSWORD@$OPENSEARCH_HOST:$OPENSEARCH_PORT"

Replace <your-cluster-host>, <your-cluster-port>, <your-cluster-username>, and <your-cluster-password> with the values you saved from the cluster’s connection details.

If you added your current IP address as a trusted source, open the terminal from the same computer and network using that IP address.

If you added a DigitalOcean resource, such as a Droplet, as a trusted source, open a terminal session from that resource.

Lastly, verify the connection:

curl -sS "$OS/" | jq '.version.number'

If successful, the command returns the OpenSearch version number.

After you store your connection details securely and set your environment variables, you can start indexing and running queries:

We can't find any results for your search.

Try using different keywords or simplifying your search terms.