All requests to Pinecone APIs must contain a valid API key for the target project.

Get an API key

Create a new API key in the Pinecone console, or use the connect widget below to generate a key.
Copy your generated key:
PINECONE_API_KEY="{{YOUR_API_KEY}}"

# This API key has ReadWrite access to all indexes in your project.

Initialize a client

When using a Pinecone SDK, initialize a client object with your API key and then reuse the authenicated client in subsquent function calls. For example:
from pinecone.grpc import PineconeGRPC as Pinecone
from pinecone import ServerlessSpec

pc = Pinecone(api_key='YOUR_API_KEY')

# Creates an index using the API key stored in the client 'pc'.
pc.create_index(
    name="docs-example",
    dimension=1536,
    metric="cosine",
    spec=ServerlessSpec(
        cloud='aws', 
        region='us-east-1'
    ) 
) 

Add headers to an HTTP request

All HTTP requests to Pinecone APIs must contain an Api-Key header that specifies a valid API key and must be encoded as JSON with the Content-Type: application/json header. For example:
curl
curl https://api.pinecone.io/indexes \
   -H "Content-Type: application/json" \
   -H "Api-Key: $PINECONE_API_KEY" \
  -H "X-Pinecone-API-Version: 2025-01" \
   -d '{
         "name":  "docs-example",
         "dimension": 1536,
         "metric": "cosine",
         "spec": {
            "serverless": {
               "cloud":"aws",
               "region": "us-east-1"
            }
         }
      }'

Troubleshooting

Older versions of Pinecone required you to initialize a client with an init method that takes both api_key and environment parameters, for example:
# Legacy initialization
import pinecone

pc = pinecone.init(
    api_key="PINECONE_API_KEY",
    environment="PINECONE_ENVIRONMENT"
)
In more recent versions of Pinecone, this has changed. Initialization no longer requires an init step, and cloud environment is defined for each index rather than an entire project. Client initialization now only requires an api_key parameter, for example:
# New initialization
from pinecone import Pinecone

pc = Pinecone(api_key="YOUR_API_KEY")
If you are receiving errors about initialization, upgrade your Pinecone SDK to the latest version, for example:
# Upgrade Pinecone SDK
pip install pinecone --upgrade
Also, note that some third-party tutorials and examples still reference the older initialization method. In such cases, follow the example above and the examples throughout the Pinecone documentation instead.