feat: add IndexModel compatibility shims for alpha API #590
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds backward compatibility properties to
IndexModelthat map old-style accessor patterns to the new alpha API structure, ensuring existing code continues to work with the new API.Problem
The alpha API (2026-01.alpha) has a different response structure than the previous API (2025-10):
spec(withserverless/pod/byocnested),dimension,metric,vector_typeat the top leveldeployment(withdeployment_type,cloud,region, etc.),schema(withfieldscontaining vector field configurations)Existing user code that accesses
index.spec.serverless.cloudorindex.dimensionwould break with the new API.Solution
Add compatibility shims to
IndexModelthat provide the old-style access patterns:specproperty: Returns aCompatibilitySpecthat builds the old.spec.serverless/.spec.pod/.spec.byocaccess patterns from the newdeploymentdatadimensionproperty: Extracts dimension fromschema.fields(finds dense vector field)metricproperty: Extracts metric fromschema.fields(finds vector field with metric)vector_typeproperty: Returns "dense" or "sparse" based on vector field type, or None for FTS-only indexesUsage Examples
Handling FTS-Only Indexes
Indexes with only text fields (no vectors) return
Nonefor vector properties:Test Plan
CompatibilitySpecwith serverless/pod/byoc deploymentsIndexModeldimension/metric/vector_type extractionindex["dimension"])Related Issues
Note
Medium Risk
Changes
IndexModelattribute resolution forspec/dimension/metric/vector_type, which may affect callers depending on priorspecparsing behavior whendeployment/schemaare missing or shaped differently. The logic is straightforward and covered by new unit tests, but it touches a commonly used wrapper.Overview
Adds a new
CompatibilitySpecwrapper (plusServerlessSpecCompat/PodSpecCompat/ByocSpecCompat) to recreate legacy.spec.serverless/.spec.pod/.spec.byocaccess from the alpha API’sdeploymentobject.Updates
IndexModelto provide backward-compatibledimension,metric, andvector_typeby extracting vector field info fromschema.fields(including sparse-vector and FTS-only cases), and replaces the previous complexspecdeserialization logic with the new deployment-based shim.Exports the new compatibility classes from
pinecone.db_control.modelsand expands unit tests to cover serverless/pod/byoc deployments, sparse vectors, FTS-only indexes, and dict-style access.Written by Cursor Bugbot for commit 8b4b59d. This will update automatically on new commits. Configure here.