An async Python client for Pinecone vector database.
pip install pinecone-async-client
import asyncio
import os
from pinecone_async import PineconeClient, Serverless
async def main():
# Get API key from environment
api_key = os.getenv("PINECONE_API_KEY")
if not api_key:
raise ValueError("PINECONE_API_KEY environment variable is not set")
async with PineconeClient(api_key=api_key) as client:
try:
# List all indexes
print("\n=== Listing all indexes ===")
indexes = await client.list_indexes()
print(indexes)
# Create a new index
print("\n=== Creating new index ===")
new_index = await client.create_index(
name="test-index",
dimension=1536,
metric="cosine",
spec=Serverless(
cloud="aws",
region="us-east-1"
)
)
print(new_index)
# Describe specific index
print("\n=== Describing index ===")
index_details = await client.describe_index("test-index")
print(index_details)
except Exception as e:
print(f"Error occurred: {e}")
if __name__ == "__main__":
asyncio.run(main())
- Full async support with context managers
- Type hints and Pydantic models
- Python 3.10+
- Simple API with clear error handling
# Clone repository
git clone https://github.com/yourusername/pinecone-async-client
cd pinecone-async-client
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
from pinecone_async import PineconeClient
client = PineconeClient(api_key="your-api-key")
list_indexes()
: List all available indexescreate_index(name, dimension, metric, spec)
: Create a new indexdescribe_index(index_name)
: Get details about a specific index
from pinecone_async import Serverless, PineconePod
# Serverless configuration
serverless = Serverless(cloud="aws", region="us-east-1")
# Pod configuration
pod = PineconePod(
environment="production",
replicas=1,
shards=1,
pod_type="p1.x1"
)
- Python 3.10+
- httpx>=0.27.2
- pydantic>=2.0.0
MIT License