Invoke Plugin Moonshot Error #577

Closed
opened 2026-02-16 10:19:48 -05:00 by yindo · 3 comments
Owner

Originally created by @zhiyzheng on GitHub (Aug 21, 2025).

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 Dify issues & Dify Official Plugins, 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

1.7.2

Plugin version

moonshot 0.0.7

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Steps to reproduce

Image

While using moonshot model as LLM, it encounters the error, shown as following:
"2025-08-21 18:12:42 api-1 | 2025-08-21 10:12:42.012 ERROR [Thread-109 (worker_with_context)] [base.py:211] - Error in stream reponse for plugin {'code': -500, 'message': '{"message":"{"args":{"description":"[models] Error: API request failed with status code 401: {\"error\":{\"message\":\"Invalid Authentication\",\"type\":\"invalid_authentication_error\"}}"},"error_type":"InvokeError","message":"[models] Error: API request failed with status code 401: {\"error\":{\"message\":\"Invalid Authentication\",\"type\":\"invalid_authentication_error\"}}"}","error_type":"PluginInvokeError","args":null}', 'data': None}"

I am now using windows docker to run DIfy 1.7.2, by using version 0.07 of plugin moonshot for model.

✔️ Error log

"2025-08-21 18:12:42 api-1 | 2025-08-21 10:12:42.012 ERROR [Thread-109 (worker_with_context)] [base.py:211] - Error in stream reponse for plugin {'code': -500, 'message': '{"message":"{"args":{"description":"[models] Error: API request failed with status code 401: {\"error\":{\"message\":\"Invalid Authentication\",\"type\":\"invalid_authentication_error\"}}"},"error_type":"InvokeError","message":"[models] Error: API request failed with status code 401: {\"error\":{\"message\":\"Invalid Authentication\",\"type\":\"invalid_authentication_error\"}}"}","error_type":"PluginInvokeError","args":null}', 'data': None}"

Originally created by @zhiyzheng on GitHub (Aug 21, 2025). ### 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 [Dify issues](https://github.com/langgenius/dify/issues) & [Dify Official Plugins](https://github.com/langgenius/dify-official-plugins/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 1.7.2 ### Plugin version moonshot 0.0.7 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Steps to reproduce <img width="2988" height="1790" alt="Image" src="https://github.com/user-attachments/assets/7ceaf289-1fad-4f61-8651-d2b1d74ba4ad" /> While using moonshot model as LLM, it encounters the error, shown as following: "2025-08-21 18:12:42 api-1 | 2025-08-21 10:12:42.012 ERROR [Thread-109 (worker_with_context)] [base.py:211] - Error in stream reponse for plugin {'code': -500, 'message': '{"message":"{\"args\":{\"description\":\"[models] Error: API request failed with status code 401: {\\\"error\\\":{\\\"message\\\":\\\"Invalid Authentication\\\",\\\"type\\\":\\\"invalid_authentication_error\\\"}}\"},\"error_type\":\"InvokeError\",\"message\":\"[models] Error: API request failed with status code 401: {\\\"error\\\":{\\\"message\\\":\\\"Invalid Authentication\\\",\\\"type\\\":\\\"invalid_authentication_error\\\"}}\"}","error_type":"PluginInvokeError","args":null}', 'data': None}" I am now using windows docker to run DIfy 1.7.2, by using version 0.07 of plugin moonshot for model. ### ✔️ Error log "2025-08-21 18:12:42 api-1 | 2025-08-21 10:12:42.012 ERROR [Thread-109 (worker_with_context)] [base.py:211] - Error in stream reponse for plugin {'code': -500, 'message': '{"message":"{\"args\":{\"description\":\"[models] Error: API request failed with status code 401: {\\\"error\\\":{\\\"message\\\":\\\"Invalid Authentication\\\",\\\"type\\\":\\\"invalid_authentication_error\\\"}}\"},\"error_type\":\"InvokeError\",\"message\":\"[models] Error: API request failed with status code 401: {\\\"error\\\":{\\\"message\\\":\\\"Invalid Authentication\\\",\\\"type\\\":\\\"invalid_authentication_error\\\"}}\"}","error_type":"PluginInvokeError","args":null}', 'data': None}"
yindo added the bug label 2026-02-16 10:19:48 -05:00
yindo closed this issue 2026-02-16 10:19:48 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 21, 2025):

The 401 "Invalid Authentication" error with the Moonshot plugin in Dify usually means the API key is missing, incorrect, or not being passed to the plugin as expected. The Moonshot plugin expects the MOONSHOT_API_KEY environment variable to be set in your Docker environment. If this variable is missing, malformed, or unauthorized, the plugin will pass it to the Moonshot API, which then returns a 401 error. The plugin does not perform local validation—it relies on the API response for error handling source.

Here’s a quick checklist to help resolve this:

  1. Make sure your MOONSHOT_API_KEY is set in your Docker Compose file or container environment. For example, in your docker-compose.yml:
    environment:
      - MOONSHOT_API_KEY=your_actual_api_key_here
    
  2. Restart your containers after updating the environment variable.
  3. You can verify the variable is set by running env | grep MOONSHOT_API_KEY inside the running container.
  4. Double-check that the API key is valid and has the necessary permissions for the Moonshot API.
  5. If you’re still seeing the error, try using the API key directly with a curl request from inside the container to confirm it works outside of Dify.

Similar issues have been reported with other OpenAI-compatible plugins in self-hosted Docker environments, often resolved by correcting the API key or endpoint configuration source.

If you’ve confirmed the API key is set and valid but still get the error, there may be a mismatch in how credentials are passed between Dify and the plugin, or a network/configuration issue in your Docker setup. Let me know if you need more detailed steps for debugging inside Docker!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Aug 21, 2025): <!-- Answer --> The 401 "Invalid Authentication" error with the Moonshot plugin in Dify usually means the API key is missing, incorrect, or not being passed to the plugin as expected. The Moonshot plugin expects the `MOONSHOT_API_KEY` environment variable to be set in your Docker environment. If this variable is missing, malformed, or unauthorized, the plugin will pass it to the Moonshot API, which then returns a 401 error. The plugin does not perform local validation—it relies on the API response for error handling [source](https://github.com/langgenius/dify-official-plugins/issues/498). Here’s a quick checklist to help resolve this: 1. Make sure your `MOONSHOT_API_KEY` is set in your Docker Compose file or container environment. For example, in your `docker-compose.yml`: ```yaml environment: - MOONSHOT_API_KEY=your_actual_api_key_here ``` 2. Restart your containers after updating the environment variable. 3. You can verify the variable is set by running `env | grep MOONSHOT_API_KEY` inside the running container. 4. Double-check that the API key is valid and has the necessary permissions for the Moonshot API. 5. If you’re still seeing the error, try using the API key directly with a curl request from inside the container to confirm it works outside of Dify. Similar issues have been reported with other OpenAI-compatible plugins in self-hosted Docker environments, often resolved by correcting the API key or endpoint configuration [source](https://github.com/langgenius/dify-official-plugins/issues/1411). If you’ve confirmed the API key is set and valid but still get the error, there may be a mismatch in how credentials are passed between Dify and the plugin, or a network/configuration issue in your Docker setup. Let me know if you need more detailed steps for debugging inside Docker! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/a89200b5-626c-41fb-b5ea-7b42e576d15b?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/a89200b5-626c-41fb-b5ea-7b42e576d15b?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/a89200b5-626c-41fb-b5ea-7b42e576d15b?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/a89200b5-626c-41fb-b5ea-7b42e576d15b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/a89200b5-626c-41fb-b5ea-7b42e576d15b?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/a89200b5-626c-41fb-b5ea-7b42e576d15b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/a89200b5-626c-41fb-b5ea-7b42e576d15b?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/1548)
Author
Owner

@zhiyzheng commented on GitHub (Aug 21, 2025):

The similar error occurs, when using Plugin of Gemini 0.4.2.
I can use Ollama to chat/run correctly, but would encounter the API key issue when using Gemini 0.4.2 and Moonshot 0.0.7.
The keys of the two model providers are confirmed to set correctly, and the configuration of Dify can load the models of the providers.

@zhiyzheng commented on GitHub (Aug 21, 2025): The similar error occurs, when using Plugin of Gemini 0.4.2. I can use Ollama to chat/run correctly, but would encounter the API key issue when using Gemini 0.4.2 and Moonshot 0.0.7. The keys of the two model providers are confirmed to set correctly, and the configuration of Dify can load the models of the providers.
Author
Owner

@dosubot[bot] commented on GitHub (Sep 7, 2025):

Hi, @zhiyzheng. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported a 401 "Invalid Authentication" error with the Moonshot plugin (v0.0.7) on Dify 1.7.2 Windows Docker, suggesting an API key problem.
  • Troubleshooting steps included verifying the MOONSHOT_API_KEY environment variable and Docker environment settings.
  • You later noted a similar API key error with the Gemini plugin (v0.4.2), despite confirmed correct key settings and successful use of Ollama.
  • This points to a potential issue with credential passing or configuration within Dify itself.
  • The issue remains unresolved with no recent updates.

Next Steps:

  • Please confirm if this issue is still relevant with the latest version of dify-official-plugins and if you have any new information.
  • If the issue is still present, you can keep the discussion open by commenting here; otherwise, I will automatically close this issue in 5 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Sep 7, 2025): Hi, @zhiyzheng. I'm [Dosu](https://dosu.dev), and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported a 401 "Invalid Authentication" error with the Moonshot plugin (v0.0.7) on Dify 1.7.2 Windows Docker, suggesting an API key problem. - Troubleshooting steps included verifying the MOONSHOT_API_KEY environment variable and Docker environment settings. - You later noted a similar API key error with the Gemini plugin (v0.4.2), despite confirmed correct key settings and successful use of Ollama. - This points to a potential issue with credential passing or configuration within Dify itself. - The issue remains unresolved with no recent updates. **Next Steps:** - Please confirm if this issue is still relevant with the latest version of dify-official-plugins and if you have any new information. - If the issue is still present, you can keep the discussion open by commenting here; otherwise, I will automatically close this issue in 5 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#577