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

To get started in your browser, use the “Pinecone quickstart” colab notebook.

1. Install an SDK

Pinecone SDKs provide convenient programmatic access to the Pinecone APIs.

Install the SDK for your preferred language:

2. Get an API key

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

Create a new API key in the Pinecone console, or use the connect widget below to generate a key. If you don’t have a Pinecone account, the widget will sign you up for the free Starter plan.

Copy your generated key:

PINECONE_API_KEY="{{YOUR_API_KEY}}"

3. Create an index

An index defines 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.

Use your API key to initialize a client, and then create a serverless index named example-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.

4. Load data

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 example-index index and use the upsert operation to write six 2-dimensional vectors into 2 distinct namespaces:

When you need to load large numbers of records, it is recommended to import from object storage or upsert in large batches.

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 query vector:

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.

6. Clean up

When you no longer need the example-index index, use the delete_index operation to delete it:

For production indexes, consider enabling deletion protection.

Next steps

Was this page helpful?