DS DevShelfHub Projects · AI tools
Tutorials / LangChain / Reference / Classes / PineconeVectorStore
Vector Store langchain-pinecone Intermediate

PineconeVectorStore: Reference Guide

By DevShelfHub

Use Pinecone cloud vector database with LangChain.

What is PineconeVectorStore?

PineconeVectorStore is LangChain's integration with Pinecone, a fully-managed cloud vector database, imported from the langchain-pinecone package. It provides indexing, similarity search, and metadata filtering at scale without managing server infrastructure.

Before using PineconeVectorStore, create a Pinecone index with the correct dimension—it must match your embedding model's output size (1536 for text-embedding-ada-002, 3072 for text-embedding-3-large). Mismatched dimensions raise a Pinecone API error at upsert time, not at initialization. The PINECONE_API_KEY environment variable is read automatically, or pass api_key explicitly.

LangChain's PineconeVectorStore exposes similarity_search(), max_marginal_relevance_search(), and add_documents(). For production RAG, Pinecone is preferred over in-process stores like Chroma because it is durable, multi-process safe, and horizontally scalable. The free Serverless tier allows one index and two million vectors—sufficient for prototyping.

When to Use

You're deploying production RAG at scale. Use Pinecone for high availability and automatic scaling.

Use Cases

  • Production RAG
  • Scalable search
  • Multi-tenant systems
  • Real-time recommendations
  • Enterprise search
  • Large datasets

Key Features

  • Cloud-managed
  • Auto-scaling
  • High availability
  • Metadata filtering
  • Hybrid search
  • Enterprise features

When NOT to Use

For development—use Chroma. For on-premise.

Notes

Index dimension must match your embedding model

Create the Pinecone index with dimension=1536 for OpenAI ada-002, dimension=768 for Cohere embed-english-v3, etc. PineconeVectorStore does not validate this at init—the mismatch only surfaces as a Pinecone API 400 error during the first upsert.

Namespace isolation for multi-tenancy

Pass namespace="user-123" to similarity_search() and add_documents() to shard a single Pinecone index by tenant. This avoids the cost of one index per tenant on paid plans.

Metadata filter syntax

Pass filter={"source": "contracts"} to similarity_search(). Metadata fields must be indexed in Pinecone before they can be filtered. Use describe_index_stats() to verify which fields are indexed.

from_documents vs add_documents

PineconeVectorStore.from_documents(docs, embeddings, index_name="...") is a one-shot class method for bulk upsert. For incremental updates, instantiate the class and call add_documents() instead.

PINECONE_API_KEY environment variable

Set PINECONE_API_KEY in your environment before instantiating PineconeVectorStore. The Pinecone client reads it automatically. Without it, the constructor raises a PineconeException. Never hardcode API keys in source files—use python-dotenv or a secrets manager.

Import

python
from langchain_pinecone import PineconeVectorStore

Initialization Parameters

Parameter Type Default Purpose
index_name str None Pinecone index name

Code Examples

Use Pinecone

python
from langchain_pinecone import PineconeVectorStore
from pinecone import Pinecone

pc = Pinecone(api_key='...')
vector_store = PineconeVectorStore(index_name='my-index', embedding=embeddings)

Search with Metadata Filter

python
results = vector_store.similarity_search(
    'What is LangChain?', k=4,
    filter={'source': 'docs'}
)

Add Documents Incrementally

python
from langchain_core.documents import Document
new_docs = [Document(page_content="LangChain v0.3 released",
    metadata={'source': 'news'})]
vector_store.add_documents(new_docs)

Common Mistakes

❌ Forget to create index first

✅ Create Pinecone index before using

Alternative Vector Stores

Store When to Use
Chroma For local development

Browse the full LangChain API reference index to explore more classes, methods, and decorators, or start with the LangChain introduction tutorial for end-to-end context on building with PineconeVectorStore and the wider framework.

PineconeVectorStore FAQ

What is PineconeVectorStore in LangChain?

Use Pinecone cloud vector database with LangChain. PineconeVectorStore is LangChain's integration with Pinecone, a fully-managed cloud vector database, imported from the langchain-pinecone package. It provides indexing, similarity search, and metadata filtering at scale without managing server infrastructure. Before using PineconeVectorStore, create a Pinecone index with the correct dimension—it must match your embedding model's output size (1536 for text-embedding-ada-002, 3072 for text-embedding-3-large). Mismatched dimens…

Which package provides PineconeVectorStore?

DevShelfHub documents PineconeVectorStore from the langchain-pinecone package. Pin your installed LangChain version and match imports to the snippet on this page.

When should I use PineconeVectorStore?

You're deploying production RAG at scale. Use Pinecone for high availability and automatic scaling.

When should I avoid using PineconeVectorStore?

For development—use Chroma. For on-premise.

How do I import PineconeVectorStore in Python?

from langchain_pinecone import PineconeVectorStore

Where can I explore more LangChain API reference pages?

Open the LangChain API reference index on DevShelfHub to browse classes, methods, and decorators, each with runnable examples, parameters, common mistakes, and cross-links.