HTTP status codes
The API uses the following HTTP status codes:Error response format
When an error occurs, the API returns a JSON object with error details:400 Bad Request errors
Missing required fields
Returned when required parameters are missing from the request:- Missing
sourcesarray in request body - Missing
querystring in request body - Empty
querystring
Validation errors
Returned when request parameters fail validation:chatModel.providerId- Chat model provider id must be providedchatModel.key- Chat model key must be providedembeddingModel.providerId- Embedding model provider id must be providedembeddingModel.key- Embedding model key must be providedoptimizationMode- Must be one of:speed,balanced,qualitymessageId- Message ID is required (for/api/chatendpoint)chatId- Chat ID is required (for/api/chatendpoint)
Missing provider fields
Returned when creating a provider without required fields:type, name, or config are missing from a provider creation request.
500 Internal Server errors
General server error
Returned when an unexpected error occurs during processing:- Model loading failure
- Database connection issues
- Search processing errors
Endpoint-specific errors
Different endpoints may return more specific error messages:Streaming errors
When using streaming mode, errors are sent as part of the stream:Best practices
Validate before sending
Validate your request data before sending it to the API:Handle errors gracefully
Implement proper error handling in your application:Retry logic
Implement retry logic for transient errors:Always implement exponential backoff when retrying failed requests to avoid overwhelming the server.
Get provider information
To avoid provider-related errors, always fetch available providers before making search requests:/api/providers endpoint.