Pinecone: upsert vectors and query an index

domain: docs.pinecone.io · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Install the pinecone-client package and initialize the client with your API key: from pinecone import Pinecone; pc = Pinecone(api_key=YOUR_KEY).
  2. Create an index if it does not exist: pc.create_index(name='INDEX_NAME', dimension=VECTOR_DIM, metric='cosine'), choosing the metric appropriate for your embeddings.
  3. Connect to the index: index = pc.Index('INDEX_NAME').
  4. Upsert vectors as a list of (id, vector, metadata) tuples: index.upsert(vectors=[('id1', [0.1, 0.2, ...], {'field': 'value'})]) in batches for large datasets.
  5. Query the index with a vector: results = index.query(vector=QUERY_VECTOR, top_k=10, include_metadata=True) to retrieve the top-k nearest neighbors.
  6. Parse results.matches to access each match's id, score, and metadata.

Known gotchas

Related routes

Upsert and query vectors in Pinecone
pinecone.io · 4 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans