Client is the main class exposed by CyborgDB TypeScript SDK. It provides an interface to interact with the CyborgDB vector database service, exposing functionality to create and list indexes. Operations within encrypted indexes (such as upsert and query) are contained within the EncryptedIndex class returned by createIndex.
Constructor
Client instance for connecting to a CyborgDB microservice.
Parameters
| Parameter | Type | Description |
|---|---|---|
baseUrl | string | Base URL of the CyborgDB microservice endpoint |
apiKey | string | (Optional) API key for authentication with the microservice |
verifySsl | boolean | (Optional) SSL verification setting. If not provided, auto-detects based on URL |
SSL Verification
The constructor includes intelligent SSL verification handling:- Auto-detection: For
localhostand127.0.0.1URLs, SSL verification is automatically disabled for development convenience - HTTP URLs: SSL verification is automatically disabled for
http://URLs - Production Safety: SSL verification is enabled by default for HTTPS URLs in production
- Manual Override: You can explicitly set
verifySslto override the auto-detection behavior
Example Usage
Error Handling
TheClient class includes comprehensive error handling that processes different types of API errors:
- HTTP Errors: Status codes and response details are logged and converted to meaningful error messages
- Validation Errors: Field validation failures are formatted with detailed information
- Network Errors: Connection and timeout issues are handled gracefully
Error objects with descriptive messages for easier debugging and error handling in your application.
Type Safety
The TypeScript SDK provides full type safety with:- Strongly typed method parameters and return values
- Type definitions for all configuration objects including
CreateIndexRequest,IndexIVFPQ,IndexIVFFlat,IndexIVF, andIndexOperationRequest - IntelliSense support in compatible IDEs
- Compile-time validation of API usage
Development Features
The client includes several development-friendly features:- Automatic SSL detection for local development environments
- Console warnings when SSL verification is disabled in production-like environments
- Node.js specific configurations for SSL handling in server environments
- Standardized headers with proper Content-Type and Accept headers