Connecting to Google AI Studio API with Appscript

Hi, I want to connect to the Google AI Studio API to interpret data from my spreadsheet and generate insights through appscript. However, I always face this error: “{“error”:{“code”:404,“message”:“models/gemini-pro is not found for API version v1, or is not supported for generateContent. Call ListModels to see the list of available models and their supported methods.”,“status”:“NOT_FOUND”}}”

My code: function generateInsightWithGeminiPro() {
const apiKey = ‘my-api-key’;

const prompt = my prompt;

const payload = {
contents: [
{
parts: [
{ text: prompt }
]
}
]
};

const url = https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent?key=${apiKey};

const options = {
method: ‘POST’,
contentType: ‘application/json’,
payload: JSON.stringify(payload),
mute

Hey @kevinpadd , Welcome to the forum

Looks like there is a small mistake in the model name. You can find the correct model variant in this documentation link.