How to list vector stores in OpenAI API
Quick answer
To list vector stores in the OpenAI API, use the OpenAI Python SDK's
Pinecone or relevant vector store client if integrated, or query your vector database service directly. The OpenAI API itself does not natively manage vector stores, so you typically list vector stores via the vector database provider's SDK or API, such as Pinecone or Chroma.PREREQUISITES
Python 3.8+OpenAI API key (free tier works)pip install openai>=1.0pip install pinecone-client (if using Pinecone vector store)
Setup
Install the OpenAI Python SDK and the Pinecone client if you use Pinecone as your vector store. Set your API keys as environment variables.
- OpenAI API key:
OPENAI_API_KEY - Pinecone API key:
PINECONE_API_KEY
pip install openai pinecone-client Step by step
Here is a complete example to list vector stores (indexes) using the Pinecone Python SDK, which is commonly used alongside OpenAI for vector storage. The OpenAI API itself does not provide vector store management endpoints.
import os
from pinecone import Pinecone
# Initialize Pinecone client
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
# List all indexes (vector stores) in your Pinecone account
indexes = pc.list_indexes()
print("Vector stores (indexes) in Pinecone:")
for idx in indexes:
print(f"- {idx}") output
Vector stores (indexes) in Pinecone: - my-vector-store-1 - semantic-search-index - embeddings-db
Common variations
If you use other vector databases like Chroma or Weaviate, you must use their respective SDKs to list vector stores. The OpenAI API focuses on model inference and embeddings but does not manage vector stores directly.
For asynchronous usage with Pinecone, use async clients provided by the vector store SDK, not the OpenAI SDK.
Troubleshooting
- If you get authentication errors, verify your
PINECONE_API_KEYenvironment variable is set correctly. - If
list_indexes()returns an empty list, confirm you have created vector stores in your Pinecone account. - The OpenAI SDK does not support vector store listing; ensure you are using the correct vector database SDK.
Key Takeaways
- OpenAI API does not natively list or manage vector stores; use your vector database SDK instead.
- Pinecone is a popular vector store provider with a Python SDK to list indexes (vector stores).
- Always use environment variables for API keys to keep credentials secure.
- Check your vector database provider's documentation for listing vector stores.
- OpenAI API focuses on embeddings and model inference, not vector store management.