PineconeApiException: (422) Reason: Unprocessable Entity

Hi, I am trying to create sparse index on local Pinecone Local development with Pinecone Local - Pinecone Docs, but when I compile this lines

sparse_index_name = "sparse-index"

if not pc.has_index(sparse_index_name):
    sparse_index_model = pc.create_index(
        name=sparse_index_name,
        vector_type="sparse",
        metric="dotproduct",
        spec=ServerlessSpec(cloud="aws", region="us-east-1"),
        deletion_protection="disabled",
        tags={"environment": "development"}
    )

which I got from pinecone guide I have this error

PineconeApiException: (422)
Reason: Unprocessable Entity
HTTP response headers: HTTPHeaderDict({'content-type': 'text/plain; charset=utf-8', 'content-length': '104', 'date': 'Wed, 02 Jul 2025 11:29:37 GMT'})
HTTP response body: Failed to deserialize the JSON body into the target type: missing field `dimension` at line 1 column 213

Could someone help me what’s going on?

Hello @szymskul and welcome to the Pinecone community forums!

The code sample for the sparse index seems to be incorrect. IIRC, you need to specify dimension=0 for sparse indexes in Pinecone local. Can you please try that and report back?

I’ve already tested it and I have this error

ValueError: dimension should not be specified for sparse indexes

OK, after actually checking, we are both right :wink: You don’t need it for the Database emulator, but you do need it for the Index emulator.

But back to the issue at hand. It is most likely because of a version mismatch. Latest Pinecone local uses API version 2025-01 while the latest Python SDK (7.x) uses API version 2025-04. Sadly, you can not force the 7.x SDK to use the older API due to breaking changes. So you’d need to downgrade the SDK to the latest 6.x version, which is 6.0.2 at the time of writing this.

1 Like

Now it works thank you :slight_smile: