# I keep getting Wrong API key from pinecone 403

**URL:** <https://community.pinecone.io/t/i-keep-getting-wrong-api-key-from-pinecone-403/5412>\
**Category:** Support\
**Tags:** serverless\
**Created:** [May 1, 2024, 10:47am UTC](https://community.pinecone.io/t/i-keep-getting-wrong-api-key-from-pinecone-403/5412 "2024-05-01T10:47:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![art.habetyan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/art.habetyan/32/1431_2.png) [@art.habetyan](https://community.pinecone.io/u/art.habetyan)\
**Post date:** [May 1, 2024, 10:47am UTC](https://community.pinecone.io/t/i-keep-getting-wrong-api-key-from-pinecone-403/5412/1 "2024-05-01T10:47:10Z")

</div>

Guys it’s my first time using VDB and i can’t understand what’s wrong with api. Here’s my code and the output.

```auto

import os
import requests
from bs4 import BeautifulSoup
import re
from fake_useragent import UserAgent
import openai
import pinecone

# Initialize Pinecone
pc = Pinecone(api_key='API-KEY')
index_name = "web"

# Check if the index exists, otherwise create one
if index_name not in pc.list_indexes().names():
    pinecone.create_index(name=index_name, dimension=1536) # Ensure dimension matches your embedding dimension
index = pinecone.Index(index_name, host='https://web-mcilcxv.svc.aped-4627-b74a.pinecone.io')

# Securely fetch your OpenAI API key
openai.api_key = openai_key

# List of website URLs
website_urls = [
    "https://www.accel.com", "https://www.a16z.com", "https://www.greylock.com",
    "https://www.benchmark.com", "https://www.sequoiacap.com", "https://www.indexventures.com",
    "https://www.kpcb.com", "https://www.lsvp.com", "https://www.matrixpartners.com",
    "https://www.500.co", "https://www.sparkcapital.com", "https://www.insightpartners.com"
]

def scrape_home_page_and_save_text(url):
    try:
        ua = UserAgent()
        headers = {'User-Agent': ua.random}
        response = requests.get(url, headers=headers)
        if response.status_code == 200:
            soup = BeautifulSoup(response.content, 'html.parser')
            text_content = re.sub(r'\s+', ' ', soup.get_text()).strip()
            print(f"Scraped {url} successfully.")
            return text_content
        else:
            print(f"Failed to scrape {url}. Status code: {response.status_code}")
            return None
    except Exception as e:
        print(f"An error occurred while scraping {url}: {str(e)}")
        return None

def embed_text_content(text_content):
    try:
        response = openai.Embedding.create(input=text_content, model="text-embedding-ada-002")
        return response['data'][0]['embedding'] # Accessing embedding data correctly
    except openai.Error as e: # Catching OpenAI specific errors
        print(f"An error occurred while generating embedding: {str(e)}")
        return None

# Scrape, embed, and store data
embeddings = []
ids = []
for url in website_urls:
    print(f"Scraping {url}...")
    text_content = scrape_home_page_and_save_text(url)
    if text_content:
        print(f"Embedding content from {url}...")
        embedding = embed_text_content(text_content)
        if embedding:
            embeddings.append(list(embedding))
            ids.append(url)

# Batch upsert to Pinecone
if embeddings and ids:
    index.upsert(vectors=list(zip(ids, embeddings)))
    print(f"Data for all sites uploaded to Pinecone.")

print("Scraping, embedding, and uploading finished.")

```

```auto
Reason: Forbidden
HTTP response headers: HTTPHeaderDict({'Date': 'Wed, 01 May 2024 10:37:34 GMT', 'Content-Type': 'text/plain', 'Content-Length': '9', 'Connection': 'keep-alive', 'x-pinecone-auth-rejected-reason': 'Wrong API key', 'www-authenticate': 'Wrong API key', 'server': 'envoy'})
HTTP response body: Forbidden

```

---

<div class="post-metadata">

**Author:** ![patrick1](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/patrick1/32/1863_2.png) [@patrick1](https://community.pinecone.io/u/patrick1)\
**Post date:** [May 1, 2024, 12:46pm UTC](https://community.pinecone.io/t/i-keep-getting-wrong-api-key-from-pinecone-403/5412/2 "2024-05-01T12:46:42Z")

</div>

Hello @art.habetyan, welcome to the forums!

Can you provide the full stack trace? I want to know which line it’s failing on.

The one thing that to note, there is no need to set the `host`. To connect to index the code is:

```python
from pinecone import Pinecone
pc = Pinecone(api_key='API-KEY')
index_name = "web"
index = pinecone.Index(index_name)

```

---

<div class="post-metadata">

**Author:** ![chris0956231181](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/chris0956231181/32/2592_2.png) [@chris0956231181](https://community.pinecone.io/u/chris0956231181)\
**Post date:** [May 8, 2024, 7:35pm UTC](https://community.pinecone.io/t/i-keep-getting-wrong-api-key-from-pinecone-403/5412/3 "2024-05-08T19:35:47Z")

</div>

i had the same problem. what worked for me was uninstalling the langchain extensions related to pinecone,Updating pinecoin to the newest version (ATM langchain conflicts with the newest version of pinecone, so this one is cruicial) . Removing all the imports of anything that could have Pinecone class (ex. langchain.vectorstores.\*). To make double-sure that I init the right Pinecone i even did it through foo=pinecone.Pinecone(…)
