See the Pinecone Node.JS SDK documentation for full installation instructions, usage examples, and reference information.

To make a feature request or report an issue, please file an issue.

Install

To install the latest version of the Node.js SDK, written in TypeScript, run the following command:

npm install @pinecone-database/pinecone

To check your SDK version, run the following command:

npm list | grep @pinecone-database/pinecone

Upgrade

If you already have the Node.js SDK, upgrade to the latest version as follows:

npm install @pinecone-database/pinecone@latest

Initialize

Once installed, you can import the library and then use an API key to initialize a client instance:

import { Pinecone } from '@pinecone-database/pinecone';

const pc = new Pinecone({
    apiKey: 'YOUR_API_KEY'
});

Proxy configuration

If your network setup requires you to interact with Pinecone through a proxy, you can pass a custom ProxyAgent from the undici library. Below is an example of how to construct an undici ProxyAgent that routes network traffic through a mitm proxy server while hitting Pinecone’s /indexes endpoint.

The following strategy relies on Node’s native fetch implementation, released in Node v16 and stabilized in Node v21. If you are running Node versions 18-21, you may experience issues stemming from the instability of the feature. There are currently no known issues related to proxying in Node v18+.

JavaScript
import {
  Pinecone,
  type PineconeConfiguration,
} from '@pinecone-database/pinecone';
import { Dispatcher, ProxyAgent } from 'undici';
import * as fs from 'fs';

const cert = fs.readFileSync('path/to/mitmproxy-ca-cert.pem');

const client = new ProxyAgent({
  uri: 'https://your-proxy.com',
  requestTls: {
    port: 'YOUR_PROXY_SERVER_PORT',
    ca: cert,
    host: 'YOUR_PROXY_SERVER_HOST',
  },
});

const customFetch = (
  input: string | URL | Request,
  init: RequestInit | undefined
) => {
  return fetch(input, {
    ...init,
    dispatcher: client as Dispatcher,
    keepalive: true,  # optional
  });
};

const config: PineconeConfiguration = {
  apiKey:
    'YOUR_API_KEY',
  fetchApi: customFetch,
};

const pc = new Pinecone(config);

const indexes = async () => {
  return await pc.listIndexes();
};

indexes().then((response) => {
  console.log('My indexes: ', response);
});

Was this page helpful?