Skip to main content
Pinecone is a vector database that helps power AI for some of the world’s best companies. This guide provides a quick overview for getting started with Pinecone vector stores. For detailed documentation of all PineconeStore features and configurations head to the API reference.

Overview

Integration details

Setup

To use Pinecone vector stores, create a Pinecone account, initialize an index, and install @langchain/pinecone, @langchain/core, and the official Pinecone SDK (@pinecone-database/pinecone v5.x) to initialize a client for PineconeStore. This guide uses OpenAI embeddings as an example. You can use other supported embeddings models instead.

Credentials

Sign up for a Pinecone account and create an index. Make sure the dimensions match those of the embeddings you want to use (the default is 1536 for OpenAI’s text-embedding-3-small). Once you’ve done this set the PINECONE_INDEX, PINECONE_API_KEY, and (optionally) PINECONE_ENVIRONMENT environment variables:
If you are using OpenAI embeddings for this guide, set your OpenAI key as well:
If you want to get automated tracing of your model calls you can also set your LangSmith API key by uncommenting below:

Instantiation

Manage vector store

Add items to vector store

Note: After adding documents, there is a slight delay before they become queryable.

Delete items from vector store

Query vector store

Once your vector store has been created and the relevant documents have been added you will most likely wish to query it during the running of your chain or agent.

Query directly

Performing a simple similarity search can be done as follows:
If you want to execute a similarity search and receive the corresponding scores you can run:

Query by turning into retriever

You can also transform the vector store into a retriever for easier usage in your chains.

Usage for retrieval-augmented generation

For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:

API reference

For detailed documentation of all PineconeStore features and configurations head to the API reference.