Skip to main content

Create Collection

Create a new vector collection with a fixed dimension and distance metric.

POST /v1/collections

Request

Headers:

x-api-key: your-api-key
Content-Type: application/json

Body:

FieldTypeRequiredDescription
namestringUnique collection name (letters, numbers, hyphens, underscores)
dimintegerVector dimension. Must match your embedding model.
distance_metricstringOne of cosine, l2, or ip. Default: cosine

Example

curl -X POST http://localhost:8000/v1/collections \
-H "x-api-key: test-key" \
-H "Content-Type: application/json" \
-d '{
"name": "articles",
"dim": 384,
"distance_metric": "cosine"
}'

Response

{
"status": "success",
"data": {
"name": "articles",
"dim": 384,
"distance_metric": "cosine",
"vector_count": 0,
"created_at": "2024-01-15T10:00:00Z"
}
}

Errors

CodeReason
409A collection with this name already exists
422Invalid request body (missing required fields, invalid dim)
401Missing or invalid API key
403API key does not have write permission