Using Collections via API
This guide covers how to use xAI Collections programmatically through the API.
Overview
Collections allow you to organize and search through documents using the xAI API. You can:
- Create and manage collections
- Upload documents to collections
- Search documents using semantic search
- Use collections in chat completions
API Endpoints
All Collections API endpoints use the Management API base URL:
Base URL: https://management-api.x.ai/v1/collections
Authentication
Use your Management API key:
Authorization: Bearer YOUR_MANAGEMENT_API_KEYCreating a Collection
POST /v1/collectionsListing Collections
GET /v1/collectionsAdding Documents
POST /v1/collections/COLLECTION_ID/documents/FILE_IDSearching Documents
Use the main API endpoint for search:
POST https://api.x.ai/v1/documents/searchFor complete API reference, see the Collections API documentation.