Creating Serverless Indexes

1. Creating Serverless Index

Example: Python

from pinecone import Pinecone, ServerlessSpec

pc = Pinecone(api_key="...")
pc.create_index(
    name="products",
    dimension=1536,
    metric="cosine",
    spec=ServerlessSpec(cloud="aws", region="us-east-1"),
    deletion_protection="enabled",
)

Example: Node.js

await pc.createIndex({
  name: "products",
  dimension: 1536,
  metric: "cosine",
  spec: { serverless: { cloud: "aws", region: "us-east-1" } },
  deletionProtection: "enabled",
});
ParamDescription
nameLowercase, alphanumeric+hyphen, max 45 chars
dimension1–20000; must match embedding model
metriccosine | dotproduct | euclidean
specServerlessSpec with cloud+region

2. Configuring Cloud Provider

CloudCodeNotes
AWS"aws"Most regions, lowest latency for many
GCP"gcp"Good for GCP-native stacks
Azure"azure"Limited regions

3. Selecting Region

CloudRegion Codes
AWSus-east-1, us-west-2, eu-west-1
GCPus-central1, europe-west4
Azureeastus2
Note: Co-locate Pinecone index with your application servers and embedding API to minimize latency.

4. Setting Index Dimensions

RuleDetail
Must match embedding model1536 for OpenAI 3-small, 3072 for 3-large
ImmutableCannot change after creation; recreate to alter
Range1 to 20000

5. Configuring Distance Metric

MetricWhen
cosineDefault for text embeddings
dotproductRequired for hybrid (sparse+dense)
euclideanSpatial / image features

6. Setting Deletion Protection

Example: Toggle Protection

pc.configure_index("products", deletion_protection="enabled")
# To delete later:
pc.configure_index("products", deletion_protection="disabled")
pc.delete_index("products")
ValueEffect
enabledBlocks delete_index until disabled
disabledAllows deletion (default)

7. Configuring Metadata Fields

Note: Serverless indexes auto-index all metadata. Selective indexing is a pod-based feature.
Field TypeRecommendation
High-cardinality stringsAvoid as filter; use for retrieval only
Booleans / enumsIdeal for filters
TimestampsStore as UNIX int for range filters

8. Understanding Auto-Scaling Behavior

AspectBehavior
Read scalingAuto, based on QPS; no config needed
Write scalingAuto-batched; respects rate limits
Storage scalingUnlimited; billed per GB-month
Cold start~1–5s after idle period; warm afterward

9. Monitoring Index Initialization

Example: Wait for Ready

import time

while not pc.describe_index("products").status["ready"]:
    time.sleep(1)
print("Index ready")
FieldDescription
status.readyBoolean — true when accepting traffic
status.stateInitializing, Ready, Terminating
hostEndpoint URL for index ops

10. Handling Creation Errors

ErrorCauseFix
AlreadyExistsIndex name conflictUse different name or describe existing
QuotaProject index quota hitDelete unused or upgrade plan
InvalidDimensiondim < 1 or > 20000Use valid dim
RegionUnavailableCloud/region combo not supportedPick supported region