Errors
The API uses standard HTTP status codes and returns consistent error response bodies. All errors include a machine-readable error code and a human-readable message.
Error Response Format
All errors return a JSON object with an error field containing the error code, message, and HTTP status.
HTTP Status Codes
| Code | Meaning |
|---|---|
200 | Success |
400 | Bad Request -- Invalid parameters or malformed request body |
401 | Unauthorized -- Invalid or missing API key |
402 | Payment Required -- Insufficient credits to complete the request |
403 | Forbidden -- Insufficient permissions |
404 | Not Found -- Resource does not exist |
409 | Conflict -- Resource already exists (e.g., duplicate email) |
429 | Too Many Requests -- Rate limit exceeded |
500 | Internal Server Error |
Error Codes
| Code | HTTP Status | Description |
|---|---|---|
BAD_REQUEST | 400 | The request body is malformed or missing required fields |
UNAUTHORIZED | 401 | The API key is invalid, missing, or has been revoked |
INSUFFICIENT_CREDITS | 402 | Your account has insufficient credits. Please top up before retrying. |
FORBIDDEN | 403 | You do not have permission to access this resource |
NOT_FOUND | 404 | The requested resource was not found |
CONFLICT | 409 | A resource conflict occurred (e.g., duplicate registration) |
RATE_LIMIT_EXCEEDED | 429 | You have exceeded your rate limit. Wait and retry using the Retry-After header. |
MODEL_NOT_FOUND | 400 | The specified model does not exist or is inactive. Use GET /v1/models to list available models. |
UPSTREAM_ERROR | 502 | An upstream service (search, citation, etc.) returned an error or timed out |
PROVIDER_ERROR | 502 | The LLM provider returned an error (e.g., content filtered, context too long) |
BILLING_ERROR | 500 | A billing system error occurred during credit hold/settle |
SEARCH_FAILED | 500 | Paper search execution failed |
ANALYSIS_FAILED | 500 | Paper analysis execution failed |
INTERNAL_ERROR | 500 | An unexpected error occurred on our end |
Example
import requests
response = requests.post(
"https://api.qinyanai.com/v1/paper-search/google",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"query": "machine learning"}
)
if response.status_code != 200:
error = response.json()["error"]
print(f"Error {error['code']}: {error['message']}")
else:
data = response.json()
print(f"Found {len(data['data'])} papers")Response
{
"error": {
"code": "INSUFFICIENT_CREDITS",
"message": "Insufficient credits: available=0.50, required=1.00",
"detail": null
}
}