Pinecone Python SDK
Official Python SDK for the Pinecone managed vector database service. Supports serverless and pod-based indexes, vector upsert/query/delete, metadata filtering, namespaces, and integrated inference (embedding + reranking). REST client by default; optional gRPC transport for performance. Async support via PineconeAsyncio. Package was renamed from pinecone-client to pinecone in v5.1.0.
Warnings
- breaking pinecone.init() removed in v3.0. Raises AttributeError on any v3+ install. Affects all pre-2024 tutorials, YouTube courses, LangChain/LlamaIndex integration examples, and most LLM-generated Pinecone code.
- breaking Package renamed from pinecone-client to pinecone in v5.1.0. pinecone-client is now a frozen stub at v6.0.0. Having both installed causes import conflicts where the wrong version may be imported.
- breaking Python 3.9 dropped in v8.0.0 (released Nov 2025). Python 3.9 reached EOL Oct 2, 2025.
- breaking pinecone[grpc] had a breaking grpcio version bump in v4.0 to enable performance improvements. Environments with other grpcio consumers (e.g., TensorFlow, gRPC services) may see dependency conflicts.
- gotcha Serverless and pod indexes have different API surfaces. ServerlessSpec and PodSpec are not interchangeable. Attempting pod-only operations (e.g., configuring pod type, replicas) on a serverless index raises an API error.
- gotcha Index creation is asynchronous. pc.create_index() returns before the index is ready. Calling pc.Index('name') immediately after creation and then upsert/query may raise a 'not ready' or connection error.
- gotcha Metadata values must be strings, numbers, booleans, or lists of strings. Nested dicts, None values, and lists of mixed types are silently dropped or cause an API validation error.
Install
-
pip install pinecone -
pip install 'pinecone[grpc]' -
pip install 'pinecone[asyncio]' -
pip uninstall pinecone-client && pip install pinecone
Imports
- Pinecone
from pinecone import Pinecone pc = Pinecone(api_key='YOUR_API_KEY')
- pinecone (package name)
pip install pinecone
Quickstart
from pinecone import Pinecone, ServerlessSpec
pc = Pinecone(api_key='YOUR_API_KEY') # or set PINECONE_API_KEY env var
# Create serverless index
if not pc.has_index('my-index'):
pc.create_index(
name='my-index',
dimension=1536,
metric='cosine',
spec=ServerlessSpec(cloud='aws', region='us-east-1'),
)
index = pc.Index('my-index')
# Upsert vectors
index.upsert(vectors=[
{'id': 'v1', 'values': [0.1] * 1536, 'metadata': {'source': 'doc1'}},
])
# Query
results = index.query(vector=[0.1] * 1536, top_k=5, include_metadata=True)
print(results)