TypeError: __init__() got an unexpected keyword argument 'api_key' getting this error while inittializing pinecone with api key

Hi @fakhrud33 ,

Welcome to the Pinecone forum and thanks for your question!

It looks like you’re passing the api_key argument to the LangChain Pinecone VectorStore class, which doesn’t expect that argument, which is why you’re getting the error:

unexpected keyword argument `api_key` 

Here is the correct code snippet:

import os
from langchain_pinecone import PineconeVectorStore
from langchain_openai import OpenAIEmbeddings

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

index_name = "medical-chatbot"
embeddings = OpenAIEmbeddings()

vectorstore_from_texts = PineconeVectorStore.from_texts(
    text_chunks,
    index_name=index_name,
    embedding=embeddings
    )

Did you have a look at this guide for how to work with Pinecone and LangChain?

Hope this helps!

1 Like