Working with Optional Authentication
The API currently accepts dummy keys or works without authentication:Best Practices for Production
When authentication becomes required in production:- Use environment variables - Store keys securely
- Implement fallback patterns - Handle both authenticated and non-authenticated modes
- Different keys for environments - Separate development and production keys
- Monitor usage - Track API usage even without authentication
Error Handling
The Vedaya API uses standard HTTP status codes and returns detailed error messages to help troubleshoot issues.Common Status Codes
200
: Success400
: Bad Request - Check your request parameters401
: Unauthorized - Invalid or missing API key404
: Not Found - Resource doesn’t exist429
: Too Many Requests - Rate limit exceeded500
: Internal Server Error - Something went wrong on our side
Implementing Robust Error Handling
Rate Limiting and Throttling
Vedaya implements rate limiting to ensure fair usage of the API. When you exceed the rate limit, you’ll receive a429 Too Many Requests
response.
Best Practices for Handling Rate Limits
- Implement exponential backoff - Gradually increase wait time between retries
- Cache responses when possible - Reduce the number of API calls
- Batch requests - Process multiple documents in a single request
- Monitor your usage - Keep track of your API usage to avoid hitting limits
Document Processing Workflow
The Vedaya API processes documents quickly (typically in seconds). Here’s the correct workflow:Upload and Process Documents
Performance Optimization
Optimizing Document Processing
- Optimize file sizes - Compress images, remove unnecessary content
- Chunk appropriately - Adjust chunk size based on your content type
- Batch process documents - Process multiple documents in parallel
- Use appropriate PDF extractors - Choose the right tool for your document type
Optimizing Queries
- Be specific with queries - More specific queries yield better results
- Adjust top_k parameter - Only retrieve as many chunks as needed
- Cache common queries - Store results for frequently asked questions
- Use vector filtering - When available, filter by metadata to improve relevance
Webhook Integration
For production applications, consider using webhooks to receive notifications when asynchronous processes complete:Testing and Debugging
Testing Strategies
- Create a test suite - Automated tests for different API operations
- Use mock data - Test with consistent sample documents
- Test error scenarios - Ensure your app handles API errors gracefully
- Perform integration testing - Test the complete workflow
Debugging Tools
- API request logging - Log all API requests and responses
- Response inspection - Examine response bodies for error details
- Status polling - Check process status for asynchronous operations
Production Deployment Checklist
Before deploying to production:- Security audit - Ensure API keys are securely stored
- Error handling - Implement comprehensive error handling
- Rate limit management - Add backoff and retry logic
- Monitoring - Set up alerts for API failures
- Backups - Plan for data backup and recovery
- Scalability - Design for increased load
- Testing - Perform thorough testing of all API integrations