Text question processing
Process a text-based quiz question and get the answer.
Endpoint
POST /process_question
Request examples
cURL
JavaScript (fetch)
Node.js (axios)
Python (requests)
curl -X POST http://localhost:3000/process_question \
-H "X-API-Key: AIzaSyDxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"question": "What is the capital of France?"
}'
Response
{
"answers" : [
"Paris"
]
}
Image question processing
Process a screenshot or image containing a quiz question.
Endpoint
POST /process_question
Request examples
cURL
JavaScript (FormData)
Node.js (form-data)
Python (requests)
curl -X POST http://localhost:3000/process_question \
-H "X-API-Key: AIzaSyDxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-F "[email protected] "
Response
{
"answers" : [
"Option B" ,
"The answer is 42"
]
}
Supported image formats: PNG, JPEG. Maximum file size: 5MB (server.js:79)
Screen monitoring
Automatically detect if a screenshot contains a quiz question and get the answer.
Endpoint
POST /monitor_screen
How it works
Upload a screenshot
Screen Answerer detects if it contains a quiz question (server.js:349)
If detected, it automatically processes and returns the answer
If not detected, returns detected: false
Request examples
curl -X POST http://localhost:3000/monitor_screen \
-H "X-API-Key: AIzaSyDxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-F "[email protected] "
Response (question detected)
{
"detected" : true ,
"answers" : [
"Option C" ,
"Machine Learning"
]
}
Response (no question detected)
{
"detected" : false ,
"message" : "No quiz question detected in the image"
}
Custom model selection
Use the /process_question_with_key endpoint to specify a custom Gemini model.
Endpoint
POST /process_question_with_key
Available models
gemini-2.0-flash-lite (default) - Faster responses, lower cost
gemini-2.0-flash - Balanced speed and accuracy
Request examples
cURL (text question)
cURL (image question)
JavaScript
Python
curl -X POST http://localhost:3000/process_question_with_key \
-F "apiKey=AIzaSyDxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-F "model=gemini-2.0-flash" \
-F "question=What is quantum computing?"
Response
{
"answers" : [
"Quantum computing uses quantum mechanics principles to process information"
]
}
Complete integration example
Here’s a complete example that handles errors, retries, and different question types.
class ScreenAnswererClient {
constructor ( apiKey , baseUrl = 'http://localhost:3000' ) {
this . apiKey = apiKey ;
this . baseUrl = baseUrl ;
}
async processQuestion ( question ) {
const response = await fetch ( ` ${ this . baseUrl } /process_question` , {
method: 'POST' ,
headers: {
'X-API-Key' : this . apiKey ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ({ question })
});
if ( ! response . ok ) {
const error = await response . json ();
throw new Error ( ` ${ error . error } : ${ error . message } ` );
}
return await response . json ();
}
async processImage ( imageFile ) {
const formData = new FormData ();
formData . append ( 'image' , imageFile );
const response = await fetch ( ` ${ this . baseUrl } /process_question` , {
method: 'POST' ,
headers: {
'X-API-Key' : this . apiKey
},
body: formData
});
if ( ! response . ok ) {
const error = await response . json ();
throw new Error ( ` ${ error . error } : ${ error . message } ` );
}
return await response . json ();
}
async monitorScreen ( imageFile ) {
const formData = new FormData ();
formData . append ( 'image' , imageFile );
const response = await fetch ( ` ${ this . baseUrl } /monitor_screen` , {
method: 'POST' ,
headers: {
'X-API-Key' : this . apiKey
},
body: formData
});
if ( ! response . ok ) {
const error = await response . json ();
throw new Error ( ` ${ error . error } : ${ error . message } ` );
}
return await response . json ();
}
}
// Usage
const client = new ScreenAnswererClient ( 'AIzaSyDxxxxxxxxxxxxxxxxxxxxxxxxxxxx' );
try {
// Process text question
const textResult = await client . processQuestion ( 'What is 2+2?' );
console . log ( 'Text answer:' , textResult . answers );
// Process image question
const imageFile = document . querySelector ( 'input[type="file"]' ). files [ 0 ];
const imageResult = await client . processImage ( imageFile );
console . log ( 'Image answer:' , imageResult . answers );
// Monitor screen
const screenResult = await client . monitorScreen ( imageFile );
if ( screenResult . detected ) {
console . log ( 'Quiz detected:' , screenResult . answers );
}
} catch ( error ) {
console . error ( 'Error:' , error . message );
}
Rate limiting considerations
Rate limits
Per-client: 1 request per 5 seconds (server.js:87)
Global: 50 requests per minute (server.js:106)
Per-IP: 100 requests per 15 minutes (server.js:48-49)
Implement delays between requests to avoid hitting rate limits.
Delay between requests
Delay between requests
const delay = ( ms ) => new Promise ( resolve => setTimeout ( resolve , ms ));
// Wait 5 seconds between requests
await client . processQuestion ( 'Question 1' );
await delay ( 5000 );
await client . processQuestion ( 'Question 2' );