Skip to main content

Overview

Screen Answerer uses API key authentication to secure access to its endpoints. All API requests require a valid Gemini API key to process questions and images.

API key requirements

You must provide your own Google Gemini API key to use Screen Answerer. The API key must be in the correct format:
  • Format: AIza[0-9A-Za-z_-]{35}
  • Example: AIzaSyDxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Get your free Gemini API key from Google AI Studio

Providing your API key

You can pass your API key in two ways: Include the X-API-Key header in your request:
curl -X POST http://localhost:3000/process_question \
  -H "X-API-Key: AIzaSyDxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -F "[email protected]"

Option 2: Request body

Include the apiKey field in your request body:
curl -X POST http://localhost:3000/process_question_with_key \
  -F "apiKey=AIzaSyDxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -F "question=What is 2+2?"

API key validation

Screen Answerer performs validation on your API key:

Format validation

The API checks that your key matches the expected Gemini API key format. If the format is invalid, you’ll receive:
{
  "error": "Invalid API key format",
  "message": "Please provide a valid Gemini API key"
}
This validation occurs on the /process_question_with_key endpoint at server.js:402

Authentication errors

If your API key is rejected by Google’s Gemini API during processing, you’ll receive:
{
  "error": "API key error",
  "message": "Invalid API key provided. Please check your API key and try again."
}
This error is returned with HTTP status code 401 Unauthorized.

Security best practices

Never commit your API key to version control or expose it in client-side code
  • Store your API key in environment variables
  • Use the X-API-Key header method for cleaner separation
  • Rotate your API key periodically
  • Monitor your Google Cloud quota usage

Missing API key

If you don’t provide an API key, the API will return:
{
  "error": "API key is required"
}
This error is returned with HTTP status code 400 Bad Request.

Build docs developers (and LLMs) love