You haven't specified an Api-Key

I’m trying to populate existing index with new records (embedded chunks) using

PineconeVectorStore.from_documents()

but I’m getting this error:

## PineconeConfigurationError("You haven't specified an Api-Key.") pinecone.exceptions.PineconeConfigurationError: You haven't specified an Api-Key

Even when I’m setting pinecone_api_key correctly in the constructor PineconeVectorStore

Do you have any idea how to fix it?

Hello @antonio.jdlsc, thank you for posting, and welcome to the forums.

For LangChain the Pinecone API-Key has to be set as an environment variable.

os.environ['PINECONE_API_KEY'] = '<YOUR_PINECONE_API_KEY>'

Please note that the case does matter.

Here is a full code snippet:

    import os
    from langchain_pinecone import PineconeVectorStore
    from langchain_openai import OpenAIEmbeddings
    from langchain_community.document_loaders import TextLoader
    from langchain_text_splitters import CharacterTextSplitter

    os.environ['OPENAI_API_KEY'] = '<YOUR_OPENAI_API_KEY>'
    os.environ['PINECONE_API_KEY'] = '<YOUR_PINECONE_API_KEY>'

    index_name = "<YOUR_PINECONE_INDEX_NAME>"
    embeddings = OpenAIEmbeddings()

    # path to an example text file
    loader = TextLoader("../../modules/state_of_the_union.txt")
    documents = loader.load()
    text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
    docs = text_splitter.split_documents(documents)

    vectorstore_from_docs = PineconeVectorStore.from_documents(
        docs,
        index_name=index_name,
        embedding=embeddings
    )

For more information, please see our LangChain guide.