403 Forbidden (Wrong API Key)

# Initialize Pinecone client
pc = Pinecone(
        api_key=KEY
    )

# Create or connect to an existing index
if NAME not in pc.list_indexes().names():
    pc.create_index(
        name=NAME ,
        dimension=1536,
        metric='cosine',
        spec=ServerlessSpec(cloud='aws', region='us-east-1')
    )
    while not pc.describe_index(index_name).status['ready']:
        time.sleep(1)
# Connect to the index
index = pinecone.Index(NAME , HOST)

This code here works I get no errors. The following line is where I get my error:

vectors = [(f'doc_{i}', embedding) for i, embedding in enumerate(document_embeddings)]
index.upsert(vectors)

Any idea what the 403 error might be related to?

Hi @kevinroy2015, and welcome to the Pinecone community forums!

Thank you for your question.

  1. To confirm, you are able to see the list of Pinecone indexes in your current project returned successfully by the first code block you shared?
  2. Could you please try creating a new project in app.pinecone.io and using the API key from that new project - do you get the same result?

Best,
Zack