/process_question endpoint processes quiz questions from either text input or uploaded images. It uses Google’s Gemini AI to analyze the question and provide accurate answers.
Endpoint
Authentication
Requires a valid Gemini API key provided via:- Recommended:
X-API-Keyheader - Alternative:
apiKeyin request body
Request parameters
Headers
Your Google Gemini API key (recommended method)
application/jsonfor text questionsmultipart/form-datafor image uploads
Body parameters
The quiz question text (for text-based questions)
Image file containing the quiz question (for image-based questions)Constraints:
- Maximum size: 5MB
- Supported formats: PNG, JPEG
- MIME type validation enforced
Your Gemini API key (alternative to header, not recommended)
Provide either
question (text) or image (file), not both.Response
Array of answer strings extracted from the AI responseEach answer is:
- Trimmed of whitespace
- Filtered to remove empty lines
- Cleaned of markdown formatting (lines starting with
*or#)
Examples
Text question
Image question
Response format
Success Response (200)
Error responses
400 Bad Request
400 Bad Request
Missing required dataMissing API keyInvalid file type (from multer)
500 Internal Server Error
500 Internal Server Error
Processing failure
Implementation details
Text processing (server.js:174-194)
Text questions are processed using this optimized prompt:Image processing (server.js:197-231)
Images are:- Converted to base64 format
- Sent to Gemini’s vision model with MIME type (PNG or JPEG)
- Processed with a concise prompt for faster responses
- Automatically deleted after processing
Answer formatting (server.js:297-299)
The API cleans AI responses by:- Splitting on newlines
- Trimming whitespace
- Filtering empty lines
- Removing markdown formatting (lines starting with
*or#)
Rate limiting
This endpoint is subject to:- Global rate limit: 100 requests per 15 minutes per IP
- Internal quota: 50 API calls per minute
Best practices
The API uses automatic retry logic with exponential backoff for transient errors. See Error Handling for details.
Related endpoints
- Monitor Screen - Automatic question detection from screen captures
- Authentication - API key setup and security
- Examples - Complete integration examples