How to beginner · 3 min read

How to delete vectors from Pinecone

Quick answer
To delete vectors from a Pinecone index, use the delete method of the Pinecone client specifying vector IDs or a filter. This removes the vectors from the index immediately. Use the official Pinecone Python SDK and authenticate with your API key.

PREREQUISITES

  • Python 3.8+
  • Pinecone API key
  • pip install pinecone-client

Setup

Install the Pinecone Python client and set your API key as an environment variable.

bash
pip install pinecone-client

Step by step

Use the Pinecone client to connect to your index and delete vectors by their IDs.

python
import os
import pinecone

# Initialize Pinecone client
pinecone.init(api_key=os.environ["PINECONE_API_KEY"], environment="us-west1-gcp")

# Connect to your index
index = pinecone.Index("your-index-name")

# Delete vectors by IDs
vector_ids_to_delete = ["vec1", "vec2", "vec3"]
index.delete(ids=vector_ids_to_delete)

print(f"Deleted vectors: {vector_ids_to_delete}")
output
Deleted vectors: ['vec1', 'vec2', 'vec3']

Common variations

You can delete vectors using a filter instead of IDs, or delete all vectors by passing no arguments.

python
import os
import pinecone

pinecone.init(api_key=os.environ["PINECONE_API_KEY"], environment="us-west1-gcp")
index = pinecone.Index("your-index-name")

# Delete vectors matching a metadata filter
index.delete(filter={"category": "news"})

# Delete all vectors (use with caution)
index.delete()

Troubleshooting

  • If you get authentication errors, verify your PINECONE_API_KEY environment variable is set correctly.
  • If vectors are not deleted, confirm the IDs or filter criteria exactly match existing vectors.
  • Check your Pinecone index name and environment region for correctness.

Key Takeaways

  • Use the Pinecone Python SDK's delete method with vector IDs or filters to remove vectors.
  • Always authenticate with your Pinecone API key set in environment variables.
  • Deleting all vectors requires calling delete() with no arguments but use carefully.
  • Verify vector IDs and filters to ensure correct vectors are deleted.
  • Check environment and index names to avoid connection issues.
Verified 2026-04
Verify ↗