Skip to main content

Step 2: Connecting and Authenticating

In this step, we will connect to the database we created in Step 1 and authenticate using an API key.

Authentication

To authenticate with the database, you will need to generate an API key. To do this, navigate to the databases page and click the key symbol next to the database you want to access. Take note of the API key and the database ID.

Connecting

Once you've created a database and generated an API key, you can connect to the database using the client library.

Install the client library:

npm install @svector/client

Next let's create the basic skeleton:

const { DatabaseService } = require('@svector/client');

const region = 'us-east-2';
const apiKey = 'f4ead19a-bac7-4ff0-b379-d3f634ed180f'; // replace with your API key
const databaseId = 'f39434565486ee15'; // replace with your database ID

const client = new DatabaseService({
endpoint: `https://${region}.api.svectordb.com`,
apiKey: apiKey
});

(async () => {
// Code goes here
})()