This page shows you how to create a serverless index. For guidance on pod-based indexes, see Using pods.

You can create an index using the Pinecone console.

Create a serverless index

You can create an index that either accepts vectors created with an external embedding model or accepts text and converts it to vectors automatically using an embedding model hosted by Pinecone.

External embedding

To create a serverless indexes for vectors created with an external embedding model, use the create_index operation as follows:

  • Provide a name for the index.
  • Specify the dimension and metric of the vectors you’ll store in the index. This should match the dimension and metric supported by your embedding model.
  • Set spec.cloud and spec.region to the cloud and region where the index should be deployed. For Python, you also need to import the ServerlessSpec class.

Other parameters are optional. See the API reference for details.

from pinecone.grpc import PineconeGRPC as Pinecone
from pinecone import ServerlessSpec

pc = Pinecone(api_key="YOUR_API_KEY")

pc.create_index(
    name="example-index",
    dimension=1536,
    metric="cosine",
    spec=ServerlessSpec(
        cloud="aws",
        region="us-east-1"
    ),
    deletion_protection="disabled",
    tags={
        "environment": "development"
    }
)

Integrated embedding

Indexes with integrated embedding do not support updating or importing with text.

To create an index that accepts source text and converts it to vectors automatically using an embedding model hosted by Pinecone, use the create_for_model operation as follows:

  • Provide a name for the index.
  • Set embed.model to one of Pinecone’s hosted embedding models.
  • Set spec.cloud and spec.region to the cloud and region where the index should be deployed.
  • Set embed.field_map to the name of the field in your source document that contains the data for embedding.

Other parameters are optional. See the API reference for details.

# pip install --upgrade pinecone
from pinecone import Pinecone
import time

pc = Pinecone(api_key="YOUR_API_KEY")

index_name = "example-index"

if not pc.has_index(index_name):
    index_model = pc.create_index_for_model(
        name=index_name,
        cloud="aws",
        region="us-east-1",
        embed={
            "model":"multilingual-e5-large",
            "field_map":{"text": "chunk_text"}
        }
    )

print(index_model)

The response will look like this:

{'deletion_protection': 'disabled',
 'dimension': 1024,
 'embed': {'dimension': 1024,
           'field_map': {'text': 'chunk_text'},
           'metric': 'cosine',
           'model': 'multilingual-e5-large',
           'read_parameters': {'input_type': 'query', 'truncate': 'END'},
           'write_parameters': {'input_type': 'passage', 'truncate': 'END'},
           'vector_type': 'dense'},
 'host': 'example-index-govk0nt.svc.aped-4627-b74a.pinecone.io',
 'id': '9e8b39c5-a142-4776-9609-e8612ad03d92',
 'metric': 'cosine',
 'name': 'example-index',
 'spec': {'serverless': {'cloud': 'aws', 'region': 'us-east-1'}},
 'status': {'ready': True, 'state': 'Ready'},
 'tags': None}

Create a serverless index from a backup

You can create a serverless index from a backup. For more details, see Restore an index.

Migrate a pod-based index to serverless

You can migrate a pod-based index to serverless by creating a new serverless index from a collection. For more information, see Migrate a pod-based index to serverless.