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.
Option A — Quick start with Google AI Studio
The fastest way to get a key for personal or small-team use:
- go to Google AI Studio → API keys and sign in with your Google account.
- Click Create API key. Choose an existing Google Cloud project or let it create one for you.
- 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:
- Open the Google Cloud Console and select (or create) a project.
- Make sure billing is enabled for the project — the Gemini API requires an active billing account beyond the free tier.
- Enable the API: go to APIs & Services → Library → Generative Language API and click Enable.
- Create a credential: APIs & Services → Credentials → Create credentials → API key.
- (Recommended) Click Restrict key and, under API restrictions, limit it to the Generative Language API so a leaked key can't be used elsewhere.
- 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:
| Model string | Description |
|---|---|
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
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
- Open your quiz, go to the Configure tab, and find AI evaluation for free-text questions.
- Set AI provider to Google AI (Gemini).
- Paste the endpoint URL into API endpoint URL (or leave it blank to use the default flash model).
- Paste your key into API key.
- Click Test configuration to verify connectivity — a green message confirms the key and endpoint work.
- 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
- HTTP 404 — the model name is wrong or unavailable to your key. For newly created keys, use the current gemini-3.8-flash default; existing explicit model identifiers remain supported when Google makes them available to your project.
- HTTP 400 / 403 — the key is invalid, the Generative Language API isn't enabled on the project, or billing is not set up.
- HTTP 429 — you've hit a rate/quota limit; check quotas in the Cloud Console.
- Answers show "Manual review" — grading failed for one of the reasons above, or the question has no model answer. Use Test configuration to see the exact error.
Reference: Google Gemini API documentation.