typescriptartificial-intelligencegoogle-geminigoogle-generativeai

Error:[GoogleGenerativeAI Eror]:Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent:[404 Not Found]


my bot was working fine few days ago and now im randomly getting the following error message

Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent: [404 Not Found] models/gemini-pro is not found for API version v1beta, or is not supported for generateContent. Call ListModels to see the list of available models and their supported methods.

running latest version of gemini package my config

{
    "token": "xxxx",
    "gemini": {
        "api": "xxx",
        "name": "gemini-pro",
        "generationConfig": {
            "temperature": 0.9,
            "topK": 40,
            "topP": 0.8,
            "maxOutputTokens": 2048
        }
    }
}

i tried new api key and updated my packages


Solution

  • From your error it seems like gemini-pro does not exist and you get Error 404 when calling it. Looking at a list of gemini models I can't see gemini-pro. The nearest one is gemini-1.5-pro. To make your script working again you have to change your gemini package config to this:

    {
        "token": "xxxx",
        "gemini": {
            "api": "xxx",
            "name": "gemini-1.5-pro",
            "generationConfig": {
                "temperature": 0.9,
                "topK": 40,
                "topP": 0.8,
                "maxOutputTokens": 2048
            }
        }
    }
    

    Explanation of the code: By changing the model name to a valid one we make sure that we don't get the Error 404 error.