Pinecone Quickstart
Pinecone is a managed vector database. Choose a supported serverless setup and verify account, region and billing requirements before creating resources.
#Prepare access
Create an appropriate key in the console↗ and record the intended cloud/region. Keep the actual key outside code.
bashpip install pinecone
#Small vector example
pythonimport os from pinecone import Pinecone, ServerlessSpec pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"]) name = "tutorial-vectors" if name not in pc.list_indexes().names(): pc.create_index( name=name, dimension=3, metric="cosine", spec=ServerlessSpec(cloud="aws", region="us-east-1"), ) # Wait for the index's ready state before the following operations. index = pc.Index(name) index.upsert(vectors=[ ("id1", [0.1, 0.2, 0.3], {"topic": "AI"}), ("id2", [0.3, 0.4, 0.1], {"topic": "Biology"}), ]) print(index.query( vector=[0.1, 0.2, 0.3], top_k=2, include_metadata=True ))
These three-dimensional vectors are synthetic teaching data, not text embeddings or proof of retrieval quality. The original source's abbreviated 1536-dimensional example used ellipses; a real embedding workflow must provide complete vectors matching its model and index.
#Alternative ingestion
Supported integrated-embedding indexes can accept source text through a configured embedding model. This differs from supplying your own vectors; check the relevant create/upsert APIs.
#Constraints
Index dimensions must match the vectors. Namespaces can separate query scope, but application authorization still controls who may access each scope. Verify successful writes and read-back before adding more workflow layers.