# API Key Error (401)

**URL:** <https://community.pinecone.io/t/api-key-error-401/585>\
**Category:** Support\
**Created:** [January 31, 2023, 2:13pm UTC](https://community.pinecone.io/t/api-key-error-401/585 "2023-01-31T14:13:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![evan](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@evan](https://community.pinecone.io/u/evan)\
**Post date:** [January 31, 2023, 2:13pm UTC](https://community.pinecone.io/t/api-key-error-401/585/1 "2023-01-31T14:13:35Z")

</div>

I’m looking to work through James’ Haystack Tutorial Notebook: [examples/haystack\_lfqa.ipynb at master · pinecone-io/examples · GitHub](https://github.com/pinecone-io/examples/blob/master/integrations/haystack/haystack_lfqa.ipynb)

But I can’t get through the first step given the following error:

UnauthorizedException: (401)  
Reason: Unauthorized  
HTTP response headers: HTTPHeaderDict({‘www-authenticate’: ‘API key is missing or invalid for the environment “us-west1-gcp”. Check that the correct environment is specified.’, ‘content-length’: ‘114’, ‘date’: ‘Tue, 31 Jan 2023 12:37:56 GMT’, ‘server’: ‘envoy’})  
HTTP response body: API key is missing or invalid for the environment “us-west1-gcp”. Check that the correct environment is specified.

For the following code block:

document\_store = PineconeDocumentStore(  
api\_key=‘my api key’,  
index=‘haystack-extractive-qa’,  
similarity=“cosine”,  
embedding\_dim=384  
)

I’ve used my API key in other projects without an issue, and to my understanding have all the other proper packages installed.

I’ve tried this with multiple API keys (\>12 hours apart), and even created a new account to try a fresh API key. Does anyone know what the issue can be?

---

<div class="post-metadata">

**Author:** ![evan](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@evan](https://community.pinecone.io/u/evan)\
**Post date:** [January 31, 2023, 4:42pm UTC](https://community.pinecone.io/t/api-key-error-401/585/2 "2023-01-31T16:42:35Z")

</div>

I figured it out:

The PineconeDocumentStore() function was missing: environment=“\<\<my\_enviornment\>\>”

---

<div class="post-metadata">

**Author:** ![kshitijpawar](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@kshitijpawar](https://community.pinecone.io/u/kshitijpawar)\
**Post date:** [February 18, 2023, 4:00am UTC](https://community.pinecone.io/t/api-key-error-401/585/3 "2023-02-18T04:00:11Z")

</div>

Thanks Evan I was facing the same error and your solution saved me going through the documentation.

---

<div class="post-metadata">

**Author:** ![Gettinitdone](https://avatars.discourse-cdn.com/v4/letter/g/a8b319/32.png) [@Gettinitdone](https://community.pinecone.io/u/Gettinitdone)\
**Post date:** [April 22, 2023, 12:15pm UTC](https://community.pinecone.io/t/api-key-error-401/585/4 "2023-04-22T12:15:05Z")

</div>

Sorry, new here. Is this in Pinecone? Or VSC? I am getting the error " FAILED TO CONNECT TO PINECONE **(‘401 Client Error: Unauthorized for url: [https://controller.asia-northeast1-gcp.pinecone.io/actions/whoami](https://controller.asia-northeast1-gcp.pinecone.io/actions/whoami)’, ‘API key is missing or invalid for the environment “asia-northeast1-gcp”. Check that the correct environment is specified.’)**"

---

<div class="post-metadata">

**Author:** ![Gettinitdone](https://avatars.discourse-cdn.com/v4/letter/g/a8b319/32.png) [@Gettinitdone](https://community.pinecone.io/u/Gettinitdone)\
**Post date:** [April 22, 2023, 12:15pm UTC](https://community.pinecone.io/t/api-key-error-401/585/5 "2023-04-22T12:15:44Z")

</div>

I am not located in Asia, could that be the problem?

---

<div class="post-metadata">

**Author:** ![Sam777](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@Sam777](https://community.pinecone.io/u/Sam777)\
**Post date:** [April 22, 2023, 6:45pm UTC](https://community.pinecone.io/t/api-key-error-401/585/6 "2023-04-22T18:45:49Z")

</div>

Hey @Gettinitdone  
I am also facing the same problem.

**API key is missing or invalid for the environment “asia-northeast1-gcp”. Check that the correct environment is specified.’)**"

Same Location. `asia-northeast1-gcp`

I think it maybe due high demand. Not sure just random guess.

---

<div class="post-metadata">

**Author:** ![makenoiz](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/makenoiz/32/421_2.png) [@makenoiz](https://community.pinecone.io/u/makenoiz)\
**Post date:** [April 23, 2023, 5:36am UTC](https://community.pinecone.io/t/api-key-error-401/585/7 "2023-04-23T05:36:15Z")

</div>

I have the same problem. Environment is auto set at asia-northeast1-gcp when I create my key yet I get the following error:

UnauthorizedException: (401)  
Reason: Unauthorized  
HTTP response headers: HTTPHeaderDict({‘www-authenticate’: ‘API key is missing or invalid for the environment “asia-northeast1-gcp”. Check that the correct environment is specified.’, ‘content-length’: ‘121’, ‘date’: ‘Sun, 23 Apr 2023 05:29:37 GMT’, ‘server’: ‘envoy’})  
HTTP response body: API key is missing or invalid for the environment “asia-northeast1-gcp”. Check that the correct environment is specified.

this is the code Im using:

```auto
# install initialize and store vectors in Pinecone

import pinecone
index_name = 'nameofmyindex'
pinecone.init(
    api_key="<<my key here>>",
    environment = "asia-northeast1-gcp"
)

if index_name not in pinecone.list_indexes():
    pinecone.create_index(index_name, dimension=len(embeds[0]))
# connect to index
index = pinecone.Index(index_name)

```

any help would be appreciated

---

<div class="post-metadata">

**Author:** ![irwin](https://avatars.discourse-cdn.com/v4/letter/i/53a042/32.png) [@irwin](https://community.pinecone.io/u/irwin)\
**Post date:** [April 23, 2023, 11:51am UTC](https://community.pinecone.io/t/api-key-error-401/585/8 "2023-04-23T11:51:25Z")

</div>

I have the same error (401)  
I am sure the PINECONE\_API\_KEY and PINECONE\_API\_ENV is right.

```auto
pinecone.init(
    api_key=PINECONE_API_KEY,
    environment=PINECONE_API_ENV
)

```

Is this a error of cloud service ? or there is something wrong with my local env ?

---

<div class="post-metadata">

**Author:** ![Ccsee](https://avatars.discourse-cdn.com/v4/letter/c/9e8a1a/32.png) [@Ccsee](https://community.pinecone.io/u/Ccsee)\
**Post date:** [April 23, 2023, 1:50pm UTC](https://community.pinecone.io/t/api-key-error-401/585/9 "2023-04-23T13:50:45Z")

</div>

Indeed always does not work on asia-northeast1-gcp.

---

<div class="post-metadata">

**Author:** ![irwin](https://avatars.discourse-cdn.com/v4/letter/i/53a042/32.png) [@irwin](https://community.pinecone.io/u/irwin)\
**Post date:** [April 24, 2023, 3:33am UTC](https://community.pinecone.io/t/api-key-error-401/585/10 "2023-04-24T03:33:31Z")

</div>

I can’t find the way to change my env when I generate a API\_KEY.  
If I just write another env in ’ pinecone.init ', It’s not work.  
What can I do ? 😂

---

<div class="post-metadata">

**Author:** ![Cory\_Pinecone](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/cory_pinecone/32/1712_2.png) [@Cory\_Pinecone](https://community.pinecone.io/u/Cory_Pinecone)\
**Post date:** [April 24, 2023, 7:44pm UTC](https://community.pinecone.io/t/api-key-error-401/585/12 "2023-04-24T19:44:17Z")

</div>

Hi all,

We’re having a problem with API keys in asia-northeast1-gcp. For the time being, please create a new project in a different region to set up your index.

---

<div class="post-metadata">

**Author:** ![alex.a.ibrahim](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/alex.a.ibrahim/32/348_2.png) [@alex.a.ibrahim](https://community.pinecone.io/u/alex.a.ibrahim)\
**Post date:** [April 24, 2023, 10:38pm UTC](https://community.pinecone.io/t/api-key-error-401/585/13 "2023-04-24T22:38:00Z")

</div>

Are there any instructions for creating a new project in a different region?

---

<div class="post-metadata">

**Author:** ![ulian](https://avatars.discourse-cdn.com/v4/letter/u/aca169/32.png) [@ulian](https://community.pinecone.io/u/ulian)\
**Post date:** [April 25, 2023, 1:01am UTC](https://community.pinecone.io/t/api-key-error-401/585/15 "2023-04-25T01:01:18Z")

</div>

Hi Alex, I found how to do it. Go to **Organization \> projects \> create project.** Also, I have removed the default project to do not have issues with `asia-northeast1-gcp` project.

That fixed the issue. Now, everything is working find.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/pinecone/original/1X/134c8f392831dd6e458012ac9232267238bf1e50.png)

---

<div class="post-metadata">

**Author:** ![inspirations365](https://avatars.discourse-cdn.com/v4/letter/i/ecccb3/32.png) [@inspirations365](https://community.pinecone.io/u/inspirations365)\
**Post date:** [April 25, 2023, 2:30am UTC](https://community.pinecone.io/t/api-key-error-401/585/16 "2023-04-25T02:30:13Z")

</div>

This did not work for me. I am still getting 401 errors.

---

<div class="post-metadata">

**Author:** ![obaidmuneer](https://avatars.discourse-cdn.com/v4/letter/o/2bfe46/32.png) [@obaidmuneer](https://community.pinecone.io/u/obaidmuneer)\
**Post date:** [April 25, 2023, 8:12am UTC](https://community.pinecone.io/t/api-key-error-401/585/17 "2023-04-25T08:12:45Z")

</div>

unfortunately am getting `error Error: Request failed with status code 401` error on us server moved to central based server still its not working

---

<div class="post-metadata">

**Author:** ![vladoportos](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/vladoportos/32/353_2.png) [@vladoportos](https://community.pinecone.io/u/vladoportos)\
**Post date:** [April 25, 2023, 11:20am UTC](https://community.pinecone.io/t/api-key-error-401/585/18 "2023-04-25T11:20:41Z")

</div>

I went to delete my index in asia-northeast1-gcp, and now I have just spinning circle… I can’t create new project because default project exist, and I can’t delete project because index “exists”, and I can’t delete index because the UI is broken 😃

---

<div class="post-metadata">

**Author:** ![vladoportos](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/vladoportos/32/353_2.png) [@vladoportos](https://community.pinecone.io/u/vladoportos)\
**Post date:** [April 25, 2023, 11:24am UTC](https://community.pinecone.io/t/api-key-error-401/585/19 "2023-04-25T11:24:29Z")

</div>

Solved by using API to delete the index again

---

<div class="post-metadata">

**Author:** ![inspirations365](https://avatars.discourse-cdn.com/v4/letter/i/ecccb3/32.png) [@inspirations365](https://community.pinecone.io/u/inspirations365)\
**Post date:** [April 25, 2023, 1:06pm UTC](https://community.pinecone.io/t/api-key-error-401/585/20 "2023-04-25T13:06:03Z")

</div>

I resolved this error by creating a new project in us-west1-gcp.

---

<div class="post-metadata">

**Author:** ![Gettinitdone](https://avatars.discourse-cdn.com/v4/letter/g/a8b319/32.png) [@Gettinitdone](https://community.pinecone.io/u/Gettinitdone)\
**Post date:** [April 28, 2023, 1:42pm UTC](https://community.pinecone.io/t/api-key-error-401/585/21 "2023-04-28T13:42:23Z")

</div>

This worked for me. But when I started to run Auto GPT it says “Using memory of type: LocalCache” is this correct? Or should it say Pinecone? I changed the Memory Backend to Pinecone in my VSC .env section

---

<div class="post-metadata">

**Author:** ![tom](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/tom/32/459_2.png) [@tom](https://community.pinecone.io/u/tom)\
**Post date:** [May 6, 2023, 12:54am UTC](https://community.pinecone.io/t/api-key-error-401/585/22 "2023-05-06T00:54:06Z")

</div>

Having same problem with very simple code

import pinecone

api\_key = “my API Key”

env =“us-west4-gcp”  
pinecone.init(api\_key=api\_key, enviroment=env)  
pinecone.whoami()

pinecone.init() apparently works. no error message.

whoami() fails with

(‘401 Client Error: Unauthorized for url: [https://controller.us-west1-gcp.pinecone.io/actions/whoami](https://controller.us-west1-gcp.pinecone.io/actions/whoami)’, ‘API key is missing or invalid for the environment “us-west1-gcp”. Check that the correct environment is specified.’)

Note that the environment actually is us-west4-gcp despite the error msg saying us-west1-gcp, This is a free account and I can create an index in it with the pinecone browser console.

[Next page](https://community.pinecone.io/t/api-key-error-401/585.md?page=2)
