Hello! I hope someone can shed some light on an issue i'm having.
I am having an issue with consistency when switching from Vertex API to GenAI API.
Having identical model and hyperparamters, for the same prompt generated via:
Vertex API: I get consistent results all the time.
In GenAI API: Wildly varying results.
Extracted relevant code:
For VertexAI I have:
vertexAi = new VertexAI({
project: this.PROJECT,
location: "europe-west1",
});
const model = this.vertexAi.getGenerativeModel({
model: "gemini-2.0-flash-001",
systemInstruction: systemInstruction,
generationConfig: {
temperature: 0.0,
topP: 0.1,
topK: 10,
seed: 1337,
responseMimeType: "application/json",
responseSchema: schema,
},
});
aiResponse = await model.generateContent({
contents: [
{role: "user", parts: [{text: JSON.stringify(lastUserMessage)}]},
],
});
____
For GenAI API I have:
genAI = new GoogleGenerativeAI(config.apiKey);
const model = this.genAI.getGenerativeModel({
model: "gemini-2.0-flash-001",
systemInstruction: systemInstruction
});
const aiResponse = await model.generateContent({
contents: [
{role: "user", parts: [{text: JSON.stringify(lastUserMessage)}]},
],
generationConfig: {
temperature: 0.0,
topP: 0.1,
topK: 10,
seed: 1337,
responseMimeType: "application/json",
responseSchema: schema,
},
});
Basically just the generation config moved as per the documentation.
Anyone have any insights? I'm pretty sure temperature etc is not being taken into account in my GenAI version.