Create Your First Index
- CLI
- Python SDK
- JavaScript SDK
Copy
gravixlayer vectors index create --name "my-embeddings" --dimension 1024 --metric cosine --cloud-provider AWS --region us-east-1 --index-type serverless
Copy
Creating vector index: my-embeddings
Index created successfully!
Index ID: aab489e9-98e2-4c63-a264-5010c297ba39
Name: my-embeddings
Dimension: 1024
Metric: cosine
Cloud Provider: AWS
Region: us-east-1
Index Type: serverless
Vector Type: dense
Copy
import os
from gravixlayer import GravixLayer
client = GravixLayer()
# Create a basic index
index = client.vectors.indexes.create(
name="my-embeddings",
dimension=1024,
metric="cosine",
cloud_provider="AWS",
region="us-east-1",
index_type="serverless"
)
print(f"Created index: {index.id}")
Copy
import { GravixLayer } from 'gravixlayer';
const client = new GravixLayer({
apiKey: process.env.GRAVIXLAYER_API_KEY,
});
// Create a basic index
const index = await client.vectors.indexes.create({
name: "my-embeddings",
dimension: 1024,
metric: "cosine",
cloud_provider: "AWS",
region: "us-east-1",
index_type: "serverless"
});
console.log(`Created index: ${index.id}`);
List Indexes
- CLI
- Python SDK
- JavaScript SDK
Copy
gravixlayer vectors index list
Copy
Listing vector indexes...
Found 2 index(es):
Index ID: 2e1b4b71-745b-4510-b7ab-045ffe390517
Name: protected-embeddings
Dimension: 768
Metric: euclidean
Cloud Provider: AWS
Region: east-us-1
Index Type: serverless
Vector Type: dense
Delete Protection: True
Created: 2025-09-24T17:25:47.194281Z
Copy
import os
from gravixlayer import GravixLayer
client = GravixLayer()
# List all indexes
indexes = client.vectors.indexes.list()
print(f"Total indexes: {len(indexes.indexes)}")
# Display all indexes
for idx in indexes.indexes:
protection_status = "🔒 Protected" if idx.delete_protection else "🔓 Unprotected"
print(f"📊 {idx.name}")
print(f" ID: {idx.id}")
print(f" Dimension: {idx.dimension}")
print(f" Metric: {idx.metric}")
print(f" Status: {protection_status}")
print(f" Created: {idx.created_at}")
print()
Copy
import { GravixLayer } from 'gravixlayer';
const client = new GravixLayer({
apiKey: process.env.GRAVIXLAYER_API_KEY,
});
// List all indexes
const indexes = await client.vectors.indexes.list();
console.log(`Total indexes: ${indexes.indexes.length}`);
// Display all indexes
indexes.indexes.forEach(idx => {
const protectionStatus = idx.delete_protection ? "🔒 Protected" : "🔓 Unprotected";
console.log(`📊 ${idx.name}`);
console.log(` ID: ${idx.id}`);
console.log(` Dimension: ${idx.dimension}`);
console.log(` Metric: ${idx.metric}`);
console.log(` Status: ${protectionStatus}`);
console.log(` Created: ${idx.created_at}`);
console.log();
});
Get Index Details
- CLI
- Python SDK
- JavaScript SDK
Copy
gravixlayer vectors index get <index-id>
Copy
import os
from gravixlayer import GravixLayer
client = GravixLayer()
# Get specific index details
index_id = "your_index_id_here"
detailed_index = client.vectors.indexes.get(index_id)
print("Detailed index information:")
print(f"Name: {detailed_index.name}")
print(f"ID: {detailed_index.id}")
print(f"Dimension: {detailed_index.dimension}")
print(f"Metric: {detailed_index.metric}")
print(f"Cloud Provider: {detailed_index.cloud_provider}")
print(f"Region: {detailed_index.region}")
print(f"Index Type: {detailed_index.index_type}")
print(f"Vector Type: {detailed_index.vector_type}")
print(f"Delete Protection: {detailed_index.delete_protection}")
print(f"Created At: {detailed_index.created_at}")
print(f"Updated At: {detailed_index.updated_at}")
print(f"Metadata: {detailed_index.metadata}")
Copy
import { GravixLayer } from 'gravixlayer';
const client = new GravixLayer({
apiKey: process.env.GRAVIXLAYER_API_KEY,
});
// Get specific index details
const indexId = "your_index_id_here";
const detailedIndex = await client.vectors.indexes.get(indexId);
console.log("Detailed index information:");
console.log(`Name: ${detailedIndex.name}`);
console.log(`ID: ${detailedIndex.id}`);
console.log(`Dimension: ${detailedIndex.dimension}`);
console.log(`Metric: ${detailedIndex.metric}`);
console.log(`Vector Type: ${detailedIndex.vector_type}`);
console.log(`Delete Protection: ${detailedIndex.delete_protection}`);
console.log(`Created At: ${detailedIndex.created_at}`);
console.log(`Updated At: ${detailedIndex.updated_at}`);
console.log(`Metadata: ${JSON.stringify(detailedIndex.metadata)}`);
Update Index
- CLI
- Python SDK
- JavaScript SDK
Copy
# Update metadata
gravixlayer vectors index update <index-id> --metadata '{"description":"Updated_embeddings","version":"2.0"}'
# Enable delete protection
gravixlayer vectors index update <index-id> --delete-protection true
Copy
import os
from gravixlayer import GravixLayer
client = GravixLayer()
# Update index metadata
updated_metadata = {
"description": "Updated embeddings",
"version": "2.0",
"last_updated": "2024-01-15"
}
index_id = "your-index-id"
updated_index = client.vectors.indexes.update(
index_id,
metadata=updated_metadata
)
print(f"Updated index metadata: {updated_index.metadata}")
# Enable delete protection
protected_index = client.vectors.indexes.update(
index_id,
delete_protection=True
)
print(f"Delete protection enabled: {protected_index.delete_protection}")
Copy
import { GravixLayer } from 'gravixlayer';
const client = new GravixLayer({
apiKey: process.env.GRAVIXLAYER_API_KEY,
});
const indexId = "your-index-id";
// Update index metadata
const updatedMetadata = {
description: "Updated embeddings",
version: "2.0",
last_updated: "2024-01-15"
};
const updatedIndex = await client.vectors.indexes.update(indexId, {
metadata: updatedMetadata
});
console.log(`Updated index metadata: ${JSON.stringify(updatedIndex.metadata)}`);
// Enable delete protection
const protectedIndex = await client.vectors.indexes.update(indexId, {
delete_protection: true
});
console.log(`Delete protection enabled: ${protectedIndex.delete_protection}`);
Delete Index
- CLI
- Python SDK
- JavaScript SDK
Copy
# Delete index
gravixlayer vectors index delete <index-id>
# Force delete (removes protection first)
gravixlayer vectors index delete <index-id> --force
Copy
import os
from gravixlayer import GravixLayer
client = GravixLayer()
# Delete an index (will fail if delete protection is enabled)
try:
client.vectors.indexes.delete(index_id)
print(f"Index {index_id} deleted successfully")
except Exception as e:
print(f"Failed to delete index: {e}")
# If delete protection is enabled, disable it first
try:
client.vectors.indexes.update(index_id, delete_protection=False)
client.vectors.indexes.delete(index_id)
print(f"Index {index_id} deleted after removing protection")
except Exception as e2:
print(f"Still failed to delete: {e2}")
Copy
import { GravixLayer } from 'gravixlayer';
const client = new GravixLayer({
apiKey: process.env.GRAVIXLAYER_API_KEY,
});
const indexId = "your_index_id_here";
// Delete an index (will fail if delete protection is enabled)
try {
await client.vectors.indexes.delete(indexId);
console.log(`Index ${indexId} deleted successfully`);
} catch (error) {
console.log(`Failed to delete index: ${error.message}`);
// If delete protection is enabled, disable it first
try {
await client.vectors.indexes.update(indexId, { delete_protection: false });
await client.vectors.indexes.delete(indexId);
console.log(`Index ${indexId} deleted after removing protection`);
} catch (error2) {
console.log(`Still failed to delete: ${error2.message}`);
}
}

