404 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. #17263
Replies: 4 comments 4 replies
-
|
I ran into the same error. import logging
from core.model_runtime.entities.model_entities import ModelType
from core.model_runtime.errors.validate import CredentialsValidateFailedError
from core.model_runtime.model_providers.__base.model_provider import ModelProvider
logger = logging.getLogger(__name__)
class GoogleProvider(ModelProvider):
def validate_provider_credentials(self, credentials: dict) -> None:
"""
Validate provider credentials.
If validation fails, raise an exception.
:param credentials: provider credentials defined in `provider_credential_schema`.
"""
try:
model_instance = self.get_model_instance(ModelType.LLM)
# Use `gemini-1.5-pro` for validation instead of the default.
model_instance.validate_credentials(model="gemini-1.5-pro",
credentials=credentials)
except CredentialsValidateFailedError as ex:
raise ex
except Exception as ex:
logger.exception(
f"{self.get_provider_schema().provider} credentials validation failed"
)
raise exI also wrote a (Japanese-language) blog post about the issue—feel free to use it as a reference: |
Beta Was this translation helpful? Give feedback.
-
|
For those running Dify 0.15.3 in Docker and encountering the 404 error when configuring the Google Gemini API (models/gemini-pro is not found), the solution provided by @cH6noota to modify google.py works great, but it won’t work directly in a Dockerized environment. Since Docker containers are ephemeral, you can’t just edit the source code inside the container (e.g., /app/api/core/model_runtime/model_providers/google/google.py) as changes will be lost on restart. Instead, you need to build a custom Docker image based on langgenius/dify-api:0.15.3 with the modified google.py file. Here’s how to do it: Clone the Dify repository to get the source code for version 0.15.3: Modify the google.py file located at api/core/model_runtime/model_providers/google/google.py. Update the validate_provider_credentials method to use gemini-1.5-pro (or another supported model like gemini-1.5-flash) instead of gemini-pro. The relevant section should look like: Create a Dockerfile in the dify directory to build a custom image. Below is the Dockerfile content: Build the custom image: bash Update your docker-compose.yaml (located in dify/docker/docker-compose.yaml) to use the custom image for the api and worker services: Restart the containers: Verify the fix in the Dify dashboard under Settings > Model Provider > Google Gemini. Enter your API key and save. The 404 error should be resolved. Ensure your Gemini API key has access to gemini-1.5-pro or gemini-1.5-flash. Check available models with: This approach ensures changes persist across container restarts, unlike mounting a modified file via volumes. |
Beta Was this translation helpful? Give feedback.
-
|
Solution Found: 404 v1beta error is caused by an incorrect model name alias. The Problem: The Solution: The fix is to change the model name in the code: OLD (Incorrect): MODEL_NAME = 'gemini-1.5-flash-latest' NEW (Correct): MODEL_NAME = 'gemini-flash-latest' This single change completely resolved the error on a stable Python environment (3.11.9). Additional Context for Advanced Users (e.g., Arch Linux on Python 3.13+): For users on bleeding-edge systems, please note that this model name issue was compounded by a separate library incompatibility with the new Python 3.13.7. On that version, a faulty version of the google-generativeai library was being installed, which made debugging this much harder. The ultimate solution for that environment was to use pyenv to manage a stable Python version (like 3.11 or 3.12) OR apply a specific dependency fix (pinning grpcio versions). However, for most users on stable Python versions, simply correcting the model name to gemini-flash-latest should be the definitive solution. Closing this issue as resolved. |
Beta Was this translation helpful? Give feedback.
-
|
The "404 models/gemini-pro is not found" error occurs because Google's Gemini API uses different model naming conventions and requires proper API configuration. Here's how to fix it: 1. Update to Correct Gemini Model Names: Google has deprecated 2. Verify Your API Setup in Dify:
3. Update google-generativeai Library: If you're using Dify with custom models, update the library: pip install --upgrade google-generativeai>=0.4.04. Check API Configuration: Verify these settings are correct: 5. Common Mistakes to Avoid:
6. For Dify Docker Setup: If self-hosting, ensure your environment variables are set: # In docker/.env
GOOGLE_API_KEY=your_api_key_here
GOOGLE_API_VERSION=v1Restart containers: docker-compose down
docker-compose up -d7. Test Connection: Create a simple test workflow:
Why You're Seeing This Error: Google sunsetted If Still Having Issues:
Switch to |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Self Checks
1. Is this request related to a challenge you're experiencing? Tell me about your story.
I get an api from google ai studio to use gemini in dify. However, when I try to import the api, it report the error as following.

404 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.
2. Additional context or comments
No response
Beta Was this translation helpful? Give feedback.
All reactions