Error Handling
Properly handle errors and exceptions in your application.SDK Exception Handling
REST API Error Responses
| Status Code | Meaning | Common Causes |
|---|---|---|
| 400 | Bad Request | Invalid parameters, malformed JSON |
| 401 | Unauthorized | Invalid or missing API key |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Namespace or resource doesn’t exist |
| 409 | Conflict | Namespace already exists |
| 413 | Payload Too Large | File too large (>10MB) |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server-side error |
Performance Optimization
Document Chunking
Split large documents into smaller, meaningful chunks for better search results:- General documents: 500-1000 characters
- Technical docs: 1000-2000 characters
- Legal documents: 2000-3000 characters
Batch Operations
Upload data in batches for better performance:Async Processing
For text namespaces, embedding generation is asynchronous. Add a small delay after upload:Namespace Organization
Separate by Environment
Organize by Content Type
Version Management
Metadata Best Practices
Rich Metadata
Include comprehensive metadata for better filtering:Consistent Metadata Schema
Maintain consistent metadata keys across documents:Search Optimization
Optimize top_k
Choose the right number of results:Use Metadata Filters
Combine semantic search with metadata for precision:Set Thresholds
Filter low-relevance results:AI Generation Best Practices
Choose the Right Model
Control Temperature
Use Custom Prompts
Security Best Practices
Store API keys securely
Store API keys securely
- Use environment variables
- Never commit keys to version control
- Use secret management in production
- Rotate keys regularly
Implement rate limiting
Implement rate limiting
- Add exponential backoff for retries
- Monitor API usage
- Implement client-side throttling
Validate inputs
Validate inputs
- Sanitize user inputs before searching
- Validate metadata formats
- Check file types before upload
Monitor usage
Monitor usage
- Track API call volumes
- Monitor error rates
- Set up alerts for anomalies