Skip to main content

Enable Google AI (Gemini) for AI grading

QuizMachine can automatically grade free-text answers by calling Google's Generative Language (Gemini) API. To use it you need a Google API key with the Generative Language API enabled, plus a valid model endpoint URL. This guide walks through both.

The AI only ever suggests a score and rationale — an admin always reviews before the score is applied. Your API key is stored encrypted and is never shown again after saving.

Option A — Quick start with Google AI Studio

The fastest way to get a key for personal or small-team use:

  1. go to Google AI Studio → API keys and sign in with your Google account.
  2. Click Create API key. Choose an existing Google Cloud project or let it create one for you.
  3. Copy the generated key — you'll paste it into QuizMachine's API key field.

Keys created in AI Studio already have the Generative Language API enabled, so you can skip straight to choosing an endpoint.

Option B — Google Cloud Console (organisation / billing control)

If your subscription is managed through Google Cloud, or you need quota and billing controls:

  1. Open the Google Cloud Console and select (or create) a project.
  2. Make sure billing is enabled for the project — the Gemini API requires an active billing account beyond the free tier.
  3. Enable the API: go to APIs & Services → Library → Generative Language API and click Enable.
  4. Create a credential: APIs & Services → Credentials → Create credentials → API key.
  5. (Recommended) Click Restrict key and, under API restrictions, limit it to the Generative Language API so a leaked key can't be used elsewhere.
  6. Copy the key for the next step.

Choose a model and build the endpoint URL

The endpoint URL follows this pattern:

https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent

Replace {model} with a model your project has access to. Current stable models suitable for text grading:

If you're creating a new API key, use gemini-3.8-flash, QuizMachine's current default for new Google AI configurations. Existing profiles keep their explicitly selected model.
Model stringDescription
gemini-3.8-flash Best price-performance balance for grading; QuizMachine default.
gemini-2.5-flash-lite Fastest and most budget-friendly; good for high-volume quizzes.
gemini-2.5-pro Most capable; best for nuanced rubric-based grading.
gemini-3.5-flash Latest stable; excellent reasoning and coding comprehension.
gemini-3.1-flash-lite Frontier-class performance at low cost.

So a complete, working endpoint using the default model is:

https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent
A model name that does not exist or is unavailable to your key returns HTTP 404, and grading falls back to manual review. Check current model names in the Gemini API model list.

QuizMachine calls the generateContent endpoint shown above. Google now also offers a newer Interactions API, but generateContent remains fully supported and is all a one-shot grading request like this needs — no migration required.

Newer Gemini 3 models support thinking mode. QuizMachine finds the first response part containing text and ignores empty thinking parts, so these models work like the others.

Enter the settings in QuizMachine

  1. Open your quiz, go to the Configure tab, and find AI evaluation for free-text questions.
  2. Set AI provider to Google AI (Gemini).
  3. Paste the endpoint URL into API endpoint URL (or leave it blank to use the default flash model).
  4. Paste your key into API key.
  5. Click Test configuration to verify connectivity — a green message confirms the key and endpoint work.
  6. Click Save AI settings.

Then, on any Free Text question, enable Grade this question with AI and provide a model answer. Submitted answers will be graded automatically and queued for admin review.

Troubleshooting

Reference: Google Gemini API documentation.

Back to all Help pages