Pinecone provides long-term memory for high-performance AI applications. It’s a managed, cloud-native vector database with a streamlined API and no infrastructure hassles. Pinecone serves fresh, relevant query results with low latency at the scale of billions of vectors.

This guide shows you how to set up and use a Pinecone vector database in minutes.

If you’d prefer to get started in your browser, use the “Pinecone quickstart” colab notebook.

1. Sign up for Pinecone or log in

Sign up for a free Pinecone account or log in to your existing account:

Your API key will display in the next section.

On the free Starter plan, you get 1 project, 5 serverless indexes in the us-east-1 region of AWS, and up to 2 GB of storage. Although the Starter plan has stricter limits than other plans, you can upgrade whenever you’re ready.

2. Get your API key

You need an API key to make API calls to your Pinecone project. Copy your generated key:


Alternatively, you can get your key from the Pinecone console:

  1. Open the Pinecone console.
  2. Select your project.
  3. Go to API Keys.
  4. Copy your API key.

3. Install a Pinecone client

Pinecone exposes a simple REST API for interacting with its vector database. You can use the API directly, or you can use one of the official Python (via HTTP or gRPC), Node.js, or Java clients:

4. Initialize your client connection

Using your API key, initialize your client connection to Pinecone:

When using the API directly, each HTTP request must contain an Api-Key header that specifies your API key. You’ll see this in all subsequent curl examples.

5. Create a serverless index

In Pinecone, an index is the highest-level organizational unit of data, where you define the dimension of vectors to be stored and the similarity metric to be used when querying them. Normally, you choose a dimension and similarity metric based on the embedding model used to create your vectors. For this quickstart, however, you’ll use a configuration that makes it easy to verify your query results.

Create a serverless index named docs-quickstart-index that stores vectors of 2 dimensions and performs nearest-neighbor search using the cosine similarity metric:

In this Quickstart, you are creating a serverless index in the us-east-1 region of AWS (the default). Pinecone supports multiple cloud providers and regions.

6. Upsert vectors

Within an index, vectors are stored in namespaces, and all upserts, queries, and other data operations always target one namespace:

Namespaces are essential for implementing multitenancy when you need to isolate the data of each customer/user.

Now that you’ve created your index, target the docs-quickstart-index index and use the upsert operation to write six 2-dimensional vectors into 2 distinct namespaces:

When upserting larger amounts of data, it is recommended to upsert records in large batches. This should be as large as possible (up to 1000 records) without exceeding the maximum request size of 2MB.

7. Check the index

Pinecone is eventually consistent, so there can be a delay before your upserted vectors are available to query. Use the describe_index_stats operation to check if the current vector count matches the number of vectors you upserted:

Query each namespace in your index for the 3 vectors that are most similar to an example 2-dimensional vector using the cosine similarity metric you specified for the index:

This is a simple example. As you put more demands on Pinecone, you’ll see it returning low-latency, accurate results at huge scales, with indexes of up to billions of vectors.

9. Clean up

When you no longer need the “docs-quickstart-index” index, use the delete_index operation to delete it:

After you delete an index, you cannot use it again or recover it.

Next steps

Check out the following examples and sample apps to see how you can use your serverless index:

Was this page helpful?