Skip to main content

RAG Collections

Collections organize your documents. Each collection stores documents for a specific purpose.

Creating Collections

Using API

curl -X POST http://localhost/api/v1/rag/collections \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "documentation",
"description": "Product documentation and user guides",
"embedding_model": "text-embedding-ada-002"
}'

Using Python

import requests

response = requests.post(
"http://localhost/api/v1/rag/collections",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"name": "documentation",
"description": "Product documentation and user guides",
"embedding_model": "text-embedding-ada-002"
}
)

collection = response.json()
print(f"Collection ID: {collection['id']}")
print(f"Collection Name: {collection['name']}")

Using JavaScript

const response = await fetch('http://localhost/api/v1/rag/collections', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'documentation',
description: 'Product documentation and user guides',
embedding_model: 'text-embedding-ada-002'
})
});

const collection = await response.json();
console.log(`Collection ID: ${collection.id}`);

Collection Parameters

ParameterTypeRequiredDescription
namestringYesUnique collection name
descriptionstringNoCollection description
embedding_modelstringNoModel for embeddings (default: text-embedding-ada-002)

Listing Collections

curl -X GET http://localhost/api/v1/rag/collections \
-H "Authorization: Bearer YOUR_API_KEY"
response = requests.get(
"http://localhost/api/v1/rag/collections",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)

collections = response.json()["collections"]
for col in collections:
print(f"Name: {col['name']}")
print(f"Documents: {col['document_count']}")
print(f"Created: {col['created_at']}\n")

Viewing Collection Details

curl -X GET http://localhost/api/v1/rag/collections/documentation \
-H "Authorization: Bearer YOUR_API_KEY"
response = requests.get(
"http://localhost/api/v1/rag/collections/documentation",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)

collection = response.json()
print(f"Name: {collection['name']}")
print(f"Description: {collection['description']}")
print(f"Documents: {collection['document_count']}")
print(f"Total Chunks: {collection['chunk_count']}")

Updating Collections

curl -X PUT http://localhost/api/v1/rag/collections/documentation \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"description": "Updated description for the collection"
}'
response = requests.put(
"http://localhost/api/v1/rag/collections/documentation",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"description": "Updated description for the collection"
}
)

print(f"Updated: {response.json()['message']}")

Deleting Collections

curl -X DELETE http://localhost/api/v1/rag/collections/documentation \
-H "Authorization: Bearer YOUR_API_KEY"
response = requests.delete(
"http://localhost/api/v1/rag/collections/documentation",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)

print(f"Deleted: {response.json()['message']}")

Warning: Deleting a collection removes all documents and their embeddings. This action cannot be undone.

Collection Best Practices

Naming Collections

Use clear, descriptive names:

Good NamesBad Names
product_docsdocs
support_articlesarticles
legal_contractslegal
api_referenceapi
research_paperspapers

Organizing Collections

Organize collections by purpose:

documentation/
├── user_guides
├── api_reference
├── troubleshooting
└── faqs

company/
├── policies
├── procedures
└── legal

Collection Settings

Choose embedding model based on use case:

Use CaseRecommended Model
General purposetext-embedding-ada-002
Code documentationtext-embedding-3-small
High accuracytext-embedding-3-large

Troubleshooting

Collection Name Exists

Problem: {"error": "Collection name already exists"}

Solution:

  • Choose a unique collection name
  • Delete existing collection if no longer needed
  • Use a more specific name

Collection Not Found

Problem: {"error": "Collection not found"}

Solution:

  • Verify collection name is correct
  • Check collection exists using list endpoint
  • Confirm you have access to the collection

Documents Not Appearing

Problem: Collection shows 0 documents after upload

Solution:

  • Wait for document processing to complete
  • Check upload response for errors
  • Verify file format is supported
  • Review server logs for processing issues

Next Steps