Setup OpenRouter fails with "Credentials validation failed with status code 402" #6753

Closed
opened 2026-02-21 18:17:07 -05:00 by yindo · 22 comments
Owner

Originally created by @LiviaH on GitHub (Nov 13, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • 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

  1. login to openrouter.ai
  2. Create a Key
  3. Copy the Key
  4. login to cloud.dify.ai
  5. go to Settings -> Model Provider
  6. find "OpenRouter" and click "Setup"
  7. paste the openrouter key into "API Key" field
  8. click "Save"
  9. 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"

Originally created by @LiviaH on GitHub (Nov 13, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [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 1. login to openrouter.ai 2. Create a Key 3. Copy the Key 4. login to cloud.dify.ai 5. go to Settings -> Model Provider 6. find "OpenRouter" and click "Setup" 7. paste the openrouter key into "API Key" field 8. click "Save" 9. 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"
yindo added the 🐞 bug label 2026-02-21 18:17:07 -05:00
yindo closed this issue 2026-02-21 18:17:07 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 13, 2024):

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.

@dosubot[bot] commented on GitHub (Nov 13, 2024): <!-- Greeting --> 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! <!-- Answer --> 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](https://github.com/langgenius/dify/issues/1526) and see if any of the discussions or solutions there are applicable to your situation <sup>[[1]](https://github.com/langgenius/dify/issues/1526)</sup>. 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. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@LiviaH commented on GitHub (Nov 13, 2024):

issue #1526 is not similar, you mix OpenRouter and OpenAI integration which are different cases. I assume the OpenRouter specific implementation needs to reviewed.

@LiviaH commented on GitHub (Nov 13, 2024): issue #1526 is not similar, you mix OpenRouter and OpenAI integration which are different cases. I assume the OpenRouter specific implementation needs to reviewed.
Author
Owner

@dosubot[bot] commented on GitHub (Dec 15, 2024):

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!

@dosubot[bot] commented on GitHub (Dec 15, 2024): Hi, @LiviaH. I'm [Dosu](https://dosu.dev), 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!
Author
Owner

@LiviaH commented on GitHub (Dec 27, 2024):

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"

@LiviaH commented on GitHub (Dec 27, 2024): 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"
Author
Owner

@sean-escaped commented on GitHub (Jan 16, 2025):

I got same issue in latest version of dify.ai also self-host and cloud platform when I add deepseek model

@sean-escaped commented on GitHub (Jan 16, 2025): I got same issue in latest version of dify.ai also self-host and cloud platform when I add deepseek model
Author
Owner

@guangchen017 commented on GitHub (Feb 22, 2025):

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

@guangchen017 commented on GitHub (Feb 22, 2025): 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
Author
Owner

@Ennazk commented on GitHub (Feb 27, 2025):

Still encountering this problem with deepseek

@Ennazk commented on GitHub (Feb 27, 2025): Still encountering this problem with deepseek
Author
Owner

@LukaBanovic commented on GitHub (Mar 13, 2025):

Still encountering the same issue with DeepSeek. @crazywoola

@LukaBanovic commented on GitHub (Mar 13, 2025): Still encountering the same issue with DeepSeek. @crazywoola
Author
Owner

@Pixel2075 commented on GitHub (Mar 16, 2025):

Still the same issue with deepseek

@Pixel2075 commented on GitHub (Mar 16, 2025): Still the same issue with deepseek
Author
Owner

@donnib commented on GitHub (Mar 19, 2025):

This issue is still valid, the ticket should be open and not closed

@donnib commented on GitHub (Mar 19, 2025): This issue is still valid, the ticket should be open and not closed
Author
Owner

@Arosy47 commented on GitHub (Mar 24, 2025):

Still the same issue with deepseek

@Arosy47 commented on GitHub (Mar 24, 2025): Still the same issue with deepseek
Author
Owner

@Andy7596183 commented on GitHub (Mar 25, 2025):

same issue with deepseek

@Andy7596183 commented on GitHub (Mar 25, 2025): same issue with deepseek
Author
Owner

@xjxtree commented on GitHub (Mar 27, 2025):

same errors when setting deepseek API key

@xjxtree commented on GitHub (Mar 27, 2025): same errors when setting deepseek API key
Author
Owner

@zismylove commented on GitHub (Apr 8, 2025):

same issus

@zismylove commented on GitHub (Apr 8, 2025): same issus
Author
Owner

@Aleegra commented on GitHub (Apr 8, 2025):

same errors when setting deepseek API key

@Aleegra commented on GitHub (Apr 8, 2025): same errors when setting deepseek API key
Author
Owner

@xjxtree commented on GitHub (Apr 8, 2025):

check your deepseek account balance first.

@xjxtree commented on GitHub (Apr 8, 2025): check your deepseek account balance first.
Author
Owner

@fafactx commented on GitHub (Apr 26, 2025):

same errors when setting deepseek API key.time: 2025/4/26.

@fafactx commented on GitHub (Apr 26, 2025): same errors when setting deepseek API key.time: 2025/4/26.
Author
Owner

@ehubb20 commented on GitHub (May 2, 2025):

I'm getting the same error with Open Router.

@ehubb20 commented on GitHub (May 2, 2025): I'm getting the same error with Open Router.
Author
Owner

@cyberjob001 commented on GitHub (May 13, 2025):

I have the same error with openrouter api key in self hosted dify

@cyberjob001 commented on GitHub (May 13, 2025): I have the same error with openrouter api key in self hosted dify
Author
Owner

@badspider7 commented on GitHub (May 21, 2025):

I have the same error with openrouter api key in self hosted dify

+1,how to slove this error,this is important for me.

@badspider7 commented on GitHub (May 21, 2025): > I have the same error with openrouter api key in self hosted dify +1,how to slove this error,this is important for me.
Author
Owner

@fengwang commented on GitHub (Aug 13, 2025):

Please reopen this issue. I have this issue with qwen/qwen3-coder:free

@fengwang commented on GitHub (Aug 13, 2025): Please reopen this issue. I have this issue with qwen/qwen3-coder:free
Author
Owner

@fengwang commented on GitHub (Aug 13, 2025):

@crazywoola Please consider reopening this issue.

@fengwang commented on GitHub (Aug 13, 2025): @crazywoola Please consider reopening this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6753