# pip install "pinecone[grpc]"
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="API_KEY")
pc.create_collection("example-collection", "docs-example")
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({
apiKey: 'YOUR_API_KEY'
});
await pc.createCollection({
name: "example-collection",
source: "docs-example",
});
import io.pinecone.clients.Pinecone;
public class CreateCollectionExample {
public static void main(String[] args) {
Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
pc.createCollection("example-collection", "docs-example");
}
}
PINECONE_API_KEY="YOUR_API_KEY"
curl -s "https://api.pinecone.io/collections" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-Api-Version: 2024-04" \
-d '{
"name": "example-collection",
"source": "docs-example"
}'
{
"name": "example-collection",
"status": "Initializing",
"environment": "us-east1-gcp",
"size": 10000000,
"dimension": 1536,
"vector_count": 120000
}{
"status": 400,
"error": {
"code": "INVALID_ARGUMENT",
"message": "Metric must be cosine, euclidean, or dotproduct."
}
}{
"status": 401,
"error": {
"code": "UNAUTHENTICATED",
"message": "Invalid API key."
}
}{
"status": 403,
"error": {
"code": "FORBIDDEN",
"message": "Collection exceeds quota. Maximum allowed on your account is 1. Currently have 1."
}
}{
"status": 409,
"error": {
"code": "ALREADY_EXISTS",
"message": "Resource already exists."
}
}{
"status": 422,
"error": {
"code": "INVALID_ARGUMENT",
"message": "Failed to deserialize the JSON body into the target type: missing field `metric` at line 1 column 16"
}
}{
"status": 500,
"error": {
"code": "UNKNOWN",
"message": "Internal server error"
}
}Backups
Create a collection
This operation creates a Pinecone collection.
Serverless indexes do not support collections.
POST
/
collections
# pip install "pinecone[grpc]"
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="API_KEY")
pc.create_collection("example-collection", "docs-example")
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({
apiKey: 'YOUR_API_KEY'
});
await pc.createCollection({
name: "example-collection",
source: "docs-example",
});
import io.pinecone.clients.Pinecone;
public class CreateCollectionExample {
public static void main(String[] args) {
Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
pc.createCollection("example-collection", "docs-example");
}
}
PINECONE_API_KEY="YOUR_API_KEY"
curl -s "https://api.pinecone.io/collections" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-Api-Version: 2024-04" \
-d '{
"name": "example-collection",
"source": "docs-example"
}'
{
"name": "example-collection",
"status": "Initializing",
"environment": "us-east1-gcp",
"size": 10000000,
"dimension": 1536,
"vector_count": 120000
}{
"status": 400,
"error": {
"code": "INVALID_ARGUMENT",
"message": "Metric must be cosine, euclidean, or dotproduct."
}
}{
"status": 401,
"error": {
"code": "UNAUTHENTICATED",
"message": "Invalid API key."
}
}{
"status": 403,
"error": {
"code": "FORBIDDEN",
"message": "Collection exceeds quota. Maximum allowed on your account is 1. Currently have 1."
}
}{
"status": 409,
"error": {
"code": "ALREADY_EXISTS",
"message": "Resource already exists."
}
}{
"status": 422,
"error": {
"code": "INVALID_ARGUMENT",
"message": "Failed to deserialize the JSON body into the target type: missing field `metric` at line 1 column 16"
}
}{
"status": 500,
"error": {
"code": "UNKNOWN",
"message": "Internal server error"
}
}# pip install "pinecone[grpc]"
from pinecone.grpc import PineconeGRPC as Pinecone
pc = Pinecone(api_key="API_KEY")
pc.create_collection("example-collection", "docs-example")
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone'
const pc = new Pinecone({
apiKey: 'YOUR_API_KEY'
});
await pc.createCollection({
name: "example-collection",
source: "docs-example",
});
import io.pinecone.clients.Pinecone;
public class CreateCollectionExample {
public static void main(String[] args) {
Pinecone pc = new Pinecone.Builder("YOUR_API_KEY").build();
pc.createCollection("example-collection", "docs-example");
}
}
PINECONE_API_KEY="YOUR_API_KEY"
curl -s "https://api.pinecone.io/collections" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "X-Pinecone-Api-Version: 2024-04" \
-d '{
"name": "example-collection",
"source": "docs-example"
}'
Authorizations
An API Key is required to call Pinecone APIs. Get yours from the console.
Body
application/json
The desired configuration for the collection.
The configuration needed to create a Pinecone collection.
Response
The collection has been successfully created.
The CollectionModel describes the configuration and status of a Pinecone collection.
Was this page helpful?