candidateCount worked fine on Gemini 2.x models but any value above 1 now returns a 400 error on all Gemini 3.x models I've tested, including the stable GA gemini-3.1-flash-lite. The parameter is still present and undeprecated in the SDK types, and there's been no changelog entry or announcement about this change.
Environment details
- Programming language: TypeScript / JavaScript
- OS: Windows 11
- Language runtime version: Node.js v24.1.0
- Package version:
@google/genai 2.4.0
Steps to reproduce
- Run the following:
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
const response = await ai.models.generateContent({
model: "gemini-3.1-flash-lite",
contents: "Give me a short poem about the sea.",
config: {
candidateCount: 2,
temperature: 1.0,
},
});
console.log(response.candidates);
- Returns:
{
"error": {
"code": 400,
"message": "Multiple candidates is not enabled for this model",
"status": "INVALID_ARGUMENT"
}
}
Same code with gemini-2.5-flash works fine. Also reproduced on gemini-3-flash-preview and gemini-3.1-pro-preview.
Same behavior also reported in python-genai: googleapis/python-genai#1723
candidateCountworked fine on Gemini 2.x models but any value above 1 now returns a 400 error on all Gemini 3.x models I've tested, including the stable GAgemini-3.1-flash-lite. The parameter is still present and undeprecated in the SDK types, and there's been no changelog entry or announcement about this change.Environment details
@google/genai2.4.0Steps to reproduce
{ "error": { "code": 400, "message": "Multiple candidates is not enabled for this model", "status": "INVALID_ARGUMENT" } }Same code with
gemini-2.5-flashworks fine. Also reproduced ongemini-3-flash-previewandgemini-3.1-pro-preview.Same behavior also reported in python-genai: googleapis/python-genai#1723