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

CodeMeaning
200Success
400Bad Request -- Invalid parameters or malformed request body
401Unauthorized -- Invalid or missing API key
402Payment Required -- Insufficient credits to complete the request
403Forbidden -- Insufficient permissions
404Not Found -- Resource does not exist
409Conflict -- Resource already exists (e.g., duplicate email)
429Too Many Requests -- Rate limit exceeded
500Internal Server Error

Error Codes

CodeHTTP StatusDescription
BAD_REQUEST400The request body is malformed or missing required fields
UNAUTHORIZED401The API key is invalid, missing, or has been revoked
INSUFFICIENT_CREDITS402Your account has insufficient credits. Please top up before retrying.
FORBIDDEN403You do not have permission to access this resource
NOT_FOUND404The requested resource was not found
CONFLICT409A resource conflict occurred (e.g., duplicate registration)
RATE_LIMIT_EXCEEDED429You have exceeded your rate limit. Wait and retry using the Retry-After header.
MODEL_NOT_FOUND400The specified model does not exist or is inactive. Use GET /v1/models to list available models.
UPSTREAM_ERROR502An upstream service (search, citation, etc.) returned an error or timed out
PROVIDER_ERROR502The LLM provider returned an error (e.g., content filtered, context too long)
BILLING_ERROR500A billing system error occurred during credit hold/settle
SEARCH_FAILED500Paper search execution failed
ANALYSIS_FAILED500Paper analysis execution failed
INTERNAL_ERROR500An 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
  }
}