PineconeConfigurationError: You haven't specified an Api-Key

For this code

docsearch = Pinecone.from_texts([t.page_content for t in text_chunks], embedding, index_name="testforpractical")

I got below error

PineconeConfigurationError: You haven't specified an Api-Key.

and i tried another method:

from langchain_openai import OpenAIEmbeddings  
from langchain.vectorstores import Pinecone
from pinecone import Pinecone as PineconeClient
import os

model_name = 'text-embedding-ada-002'  
embedding = OpenAIEmbeddings(  
    model= "gpt-3.5-turbo",  

PINECONE_API_KEY = os.environ.get('PINECONE_API_KEY', '----')
PINECONE_API_ENV = os.environ.get('PINECONE_API_ENV', '-----')

Create a Pinecone instance with the API key and environment

pinecone_instance = PineconeClient(api_key=PINECONE_API_KEY, environment=PINECONE_API_ENV)

index_name = "testforpractical"

Create a PineconeVectorStore instance with the Pinecone instance and index name
docsearch = Pinecone.from_texts(
    [t.page_content for t in text_chunks],

and got another error as :

PineconeConfigurationError: You haven't specified an Api-Key.

but i have specified all api key that of open ai and of pinecode both .
I was unable to solve this error since yesterday. So can anyone help me with this ?

Hi @home.rajnishadhikari, thanks for posting. For starters, please ensure that you are using v3.0.0 or newer of the Pinecone Python client. Once upgraded, you can initialize the Pinecone client using pc = Pinecone(api_key='YOUR_API_KEY') (docs).

When importing the LangChain package, you need to ensure you are using the most up-to-date package as well. The package langchain.vectorstores.Pinecone that you are using is deprecated. Instead you should be using from langchain_pinecone import PineconeVectorStore (docs).

1 Like

@zeke_pinecone Thanks for replying but I have tried all the steps that you mentioned but still I am unable to solve this issue

@home.rajnishadhikari Please share your revised code, and I’ll take a look. If you call echo $PINECONE_API_KEY, do you see your Pinecone API key?