Official Pinecone clients provide convenient access to the Pinecone API.

Python client

See the Pinecone Python client documentation for full installation instructions, usage examples, and reference information.

Install

To install the newest version of the Python client, run the following command:

pip install pinecone-client

If you already have the Python client, run the following command:

pip install pinecone-client --upgrade

To check your client version, run the following command:

pip show pinecone-client

Initialize

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

from pinecone import Pinecone

pc = Pinecone(api_key="YOUR_API_KEY")

When creating an index, import the ServerlessSpec or PodSpec class as well:

from pinecone import Pinecone, ServerlessSpec

pc = Pinecone(api_key="YOUR_API_KEY")

pc.create_index(
  name="serverless-index",
  dimension=1536,
  metric="cosine",
  spec=ServerlessSpec(
    cloud="aws",
    region="us-east-1"
  )
)

Proxy configuration

If your network setup requires you to interact with Pinecone through a proxy, you will need to pass additional configuration using optional keyword parameters:

  • proxy_url: The location of your proxy. This could be an HTTP or HTTPS URL depending on your proxy setup.
  • proxy_headers: Accepts a python dictionary which can be used to pass any custom headers required by your proxy. If your proxy is protected by authentication, use this parameter to pass basic authentication headers with a digest of your username and password. The make_headers utility from urllib3 can be used to help construct the dictionary.
  • ssl_ca_certs: By default, the client will perform SSL certificate verification using the CA bundle maintained by Mozilla in the certifi package. If your proxy is using self-signed certicates, use this parameter to specify the path to the certificate (PEM format).
  • ssl_verify: SSL verification is enabled by default, but it is disabled when set to False. It is not recommened to go into production with SSL verification disabled.
from pinecone import Pinecone
import urllib3 import make_headers

pc = Pinecone(
    api_key="YOUR_API_KEY",
    proxy_url='https://your-proxy.com',
    proxy_headers=make_headers(proxy_basic_auth='username:password'),
    ssl_ca_certs='path/to/cert-bundle.pem'
)

Node.js client

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

Install

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

npm install @pinecone-database/pinecone

If you already have the Node.js client, run the following command:

npm install @pinecone-database/pinecone@latest

To check your client version, run the following command:

npm list | grep @pinecone-database/pinecone

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'
});

Java client

See the Pinecone Java client documentation for full installation instructions and usage examples. If you’re migrating from version 0.8.x or below, see the Java v1.0.0 migration guide.

Install

To install the newest version of the Java client:

  • Make sure you have at least Java 1.8 installed.

  • Add a dependency to the current module:

    <dependency>
      <groupId>io.pinecone</groupId>
      <artifactId>pinecone-client</artifactId>
      <version>1.0.0</version>
    </dependency>
    

    Alternatively, you can download the standalone uberjar pinecone-client-1.0.0-all.jar, which bundles the Pinecone client and all dependencies together. You can include this in your classpath like you do with any third-party JAR without having to obtain the pinecone-client dependencies separately.

Initialize

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

import io.pinecone.clients.Pinecone;
import org.openapitools.client.model.*;

public class InitializeClientExample {
    public static void main(String[] args) {
        Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
    }
}

Go client

The Go client is under active development and should be considered unstable. Before a 1.0 release, there are no guarantees of backward compatibility between minor versions. See the Go client README for full installation instructions and usage examples.

Install

To install the newest version of the Go client:

Initialize

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

package main

import (
	"context"
	"fmt"
	"github.com/pinecone-io/go-pinecone/pinecone"
)

func main() {
	ctx := context.Background()

	pc, err := pinecone.NewClient(pinecone.NewClientParams{
		ApiKey: "YOUR_API_KEY",
	})