Closed betashepherd closed 5 months ago
To resolve the issue of receiving a 400 error when trying to add Google Gemini as a Model Provider in your self-hosted Dify instance (version 0.6.8, running on Docker), follow these steps:
Verify API Key Configuration:
Ensure that you have correctly configured the API key in the google.yaml
file. The configuration should include the google_api_key
as shown below:
provider: google
label:
en_US: Google
description:
en_US: Google's Gemini model.
zh_Hans: 谷歌提供的 Gemini 模型.
icon_small:
en_US: icon_s_en.svg
icon_large:
en_US: icon_l_en.svg
background: "#FCFDFF"
help:
title:
en_US: Get your API Key from Google
zh_Hans: 从 Google 获取 API Key
url:
en_US: https://ai.google.dev/
supported_model_types:
- llm
configurate_methods:
- predefined-model
provider_credential_schema:
credential_form_schemas:
- variable: google_api_key
label:
en_US: API Key
type: secret-input
required: true
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
Check API Key Validity: Make sure that the API key you are using is valid and has the necessary permissions. If the API key is incorrect or missing, it could result in a 400 error.
Enable Debug Mode for More Information: To get more detailed logs and understand why the setup is failing, you can enable debug mode in your Docker setup. Here are the steps to enable debug mode:
Locate the docker-compose.yaml
file.
Modify the LOG_LEVEL
, DEBUG
, and FLASK_DEBUG
environment variables for the api
service:
version: '3'
services:
api:
image: langgenius/dify-api:0.6.8
restart: always
environment:
LOG_LEVEL: DEBUG
DEBUG: true
FLASK_DEBUG: true
# other environment variables...
Save the changes and restart the Docker services:
docker-compose down
docker-compose up -d
Review Specific Error Messages: The specific error messages or codes that can be returned by the Google Gemini setup API endpoint in Dify include:
app_unavailable
- "App unavailable, please check your app configurations." (Code: 400)not_completion_app
- "Please check if your Completion app mode matches the right API route." (Code: 400)not_chat_app
- "Please check if your app mode matches the right API route." (Code: 400)not_workflow_app
- "Please check if your Workflow app mode matches the right API route." (Code: 400)provider_not_initialize
- "No valid model provider credentials found. Please go to Settings -> Model Provider to complete your provider credentials." (Code: 400)provider_quota_exceeded
- "Your quota for Dify Hosted Model Provider has been exhausted. Please go to Settings -> Model Provider to complete your own provider credentials." (Code: 400)model_currently_not_support
- "Dify Hosted OpenAI trial currently not support the GPT-4 model." (Code: 400)completion_request_error
- "Completion request failed." (Code: 400)These error messages can help you pinpoint the exact issue.
By following these steps, you should be able to resolve the 400 error and successfully add Google Gemini as a Model Provider in your Dify instance. If the issue persists, please provide more details from the debug logs for further assistance.
To continue the conversation, mention @dosu.
You need to ensure you computer can access google gemini service as expected, typically it should behind a proxy.
Yes, I can use Gemini no trouble with network, I am using an openwrt wifi router. For https://gemini.google.com/app works.
thks.
Self Checks
Dify version
0.6.8
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
✔️ Expected Behavior
save Google Gemini success
❌ Actual Behavior
save Google Gemini failed