Setup OpenRouter fails with "Credentials validation failed with status code 402"
Self Checks
- [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [X] Please do not modify this template :) and fill in all the required fields.
Dify version
0.11.0
Cloud or Self Hosted
Cloud
Steps to reproduce
- login to openrouter.ai
- Create a Key
- Copy the Key
- login to cloud.dify.ai
- go to Settings -> Model Provider
- find "OpenRouter" and click "Setup"
- paste the openrouter key into "API Key" field
- click "Save"
- popup with message "Credentials validation failed with status code 402" is shown
✔️ Expected Behavior
the API key is accepted and OpenRouter can used with API Key
❌ Actual Behavior
error occures, message: "Credentials validation failed with status code 402"
Hey @LiviaH! 👋 I'm here to assist you with bug fixes, answer your questions, and help you become a contributor. Let's tackle this issue together!
I couldn't find specific information about the status code 402 in the context of Dify's OpenRouter integration. However, I did find a similar closed issue related to setting the OpenAI API key, which might provide some insights or potential solutions. You can check the closed issue here and see if any of the discussions or solutions there are applicable to your situation [1].
If the issue persists, consider checking if there are any recent changes or updates in Dify version 0.11.0 that might affect the OpenRouter API key validation process, as this could be a contributing factor.
To continue talking to Dosu, mention @dosu.
issue #1526 is not similar, you mix OpenRouter and OpenAI integration which are different cases. I assume the OpenRouter specific implementation needs to reviewed.
Hi, @LiviaH. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.
Issue Summary:
- Bug reported in Dify version 0.11.0 regarding OpenRouter setup.
- Error encountered: "Credentials validation failed with status code 402" when saving an API key.
- I suggested checking a similar issue, but you clarified the difference and pointed out the need for a review of the OpenRouter-specific implementation.
- The issue remains unresolved, requiring further investigation into the OpenRouter integration.
Next Steps:
- Please confirm if this issue is still relevant to the latest version of the Dify repository. If so, you can keep the discussion open by commenting here.
- If there is no further activity, this issue will be automatically closed in 15 days.
Thank you for your understanding and contribution!
Still the same behavior in dify.ai 14.2. openrouter is on the list of model providers but is not usable. Adding the API Key is not possible and produces an error with the message "Credentials validation failed with status code 402"
I got same issue in latest version of dify.ai also self-host and cloud platform when I add deepseek model
This issue is still encountered in Dify version 0.15.3, i.e., the OpenRouter API Key cannot be configured, but a single model can be added successfully
Still encountering this problem with deepseek
Still encountering the same issue with DeepSeek. @crazywoola
Still the same issue with deepseek
This issue is still valid, the ticket should be open and not closed
Still the same issue with deepseek
same issue with deepseek
same errors when setting deepseek API key
same issus
same errors when setting deepseek API key
check your deepseek account balance first.
same errors when setting deepseek API key.time: 2025/4/26.
I'm getting the same error with Open Router.
I have the same error with openrouter api key in self hosted dify
I have the same error with openrouter api key in self hosted dify
+1,how to slove this error,this is important for me.
Please reopen this issue. I have this issue with qwen/qwen3-coder:free
@crazywoola Please consider reopening this issue.