# Invaild api key while key was used successfully in same .py earlier in script

**URL:** <https://community.pinecone.io/t/invaild-api-key-while-key-was-used-successfully-in-same-py-earlier-in-script/6654>\
**Category:** Support\
**Tags:** vector-database, error-401\
**Created:** [September 23, 2024, 4:42pm UTC](https://community.pinecone.io/t/invaild-api-key-while-key-was-used-successfully-in-same-py-earlier-in-script/6654 "2024-09-23T16:42:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![george.blueocean](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/george.blueocean/32/3264_2.png) [@george.blueocean](https://community.pinecone.io/u/george.blueocean)\
**Post date:** [September 23, 2024, 4:42pm UTC](https://community.pinecone.io/t/invaild-api-key-while-key-was-used-successfully-in-same-py-earlier-in-script/6654/1 "2024-09-23T16:42:44Z")

</div>

I used pinecone to upsert and index. It was created successfully. When i imported langchain\_pinecone PineconeVectorStore and called: vector\_store = PineconeVectorStore.from\_existing\_index(index\_name=index, embedding=embedding\_model) i received a 401 error invalid api key. originally i called from pinecone import Pinecone as PineconeClient. I set pc= PineconeClient(api\_key=“some\_data”) this created the index. I’m assuming when i call the PineconeVectorStore it is looking somewhere else?

---

<div class="post-metadata">

**Author:** ![zeke](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/zeke/32/4257_2.png) [@zeke](https://community.pinecone.io/u/zeke)\
**Post date:** [September 23, 2024, 5:16pm UTC](https://community.pinecone.io/t/invaild-api-key-while-key-was-used-successfully-in-same-py-earlier-in-script/6654/2 "2024-09-23T17:16:09Z")

</div>

Hi @george.blueocean, your assumption is correct. The LangChain package looks for an environment variable named `PINECONE_API_KEY`.

For an example, please see [Initializing a vector store](https://docs.pinecone.io/integrations/langchain#initializing-a-vector-store) in our LangChain integration docs.
