I scoured the docs for an example of how to specify the apiVersion parameter in a generate content request. I couldn't find it so I did a hard trace on the fetch() and finally figured out that it has to be in the call to getGenerativeModel():
const model =
getGenerativeModel(
{ model: modelName },
{
apiVersion: 'v1beta',
configuration: generationConfig
},
);
I believe this is about to trip up a lot of people up due to the huge number of participants in the Google AI Hackathon going on right now. The contest wants you to use the Gemini 1.5 Pro advanced API and that is only available with the v1beta API. So initially my API calls to that model were failing until I figured out how to declare request option that properly.
Post-mortem I did manage to find an example of it buried in the node /advanced-function-calling.js sample. Given it's importance I feel it should be added to the the man repo README page and also at least somewhere on the main API docs page for JavaScript developers:
https://ai.google.dev/tutorials/get_started_web
If you scan that page, you will find many getGenerativeModel() call examples, some even showing how to declare SAFETY settings, but none of them show you where to put the apiVersion option.
I scoured the docs for an example of how to specify the
apiVersionparameter in a generate content request. I couldn't find it so I did a hard trace on thefetch()and finally figured out that it has to be in the call togetGenerativeModel():I believe this is about to trip up a lot of people up due to the huge number of participants in the Google AI Hackathon going on right now. The contest wants you to use the Gemini 1.5 Pro advanced API and that is only available with the
v1betaAPI. So initially my API calls to that model were failing until I figured out how to declare request option that properly.Post-mortem I did manage to find an example of it buried in the
node /advanced-function-calling.jssample. Given it's importance I feel it should be added to the the man repo README page and also at least somewhere on the main API docs page for JavaScript developers:https://ai.google.dev/tutorials/get_started_web
If you scan that page, you will find many
getGenerativeModel()call examples, some even showing how to declare SAFETY settings, but none of them show you where to put theapiVersionoption.