Add an OpenAI-API-compatible model error. I added the grok-2-latest model. #12135

Closed
opened 2026-02-21 19:05:57 -05:00 by yindo · 3 comments
Owner

Originally created by @Tingfing6 on GitHub (Mar 25, 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 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

x

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Image

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @Tingfing6 on GitHub (Mar 25, 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 [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 x ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ![Image](https://github.com/user-attachments/assets/c5d1fb61-32a2-466d-b7de-f4ddc9599ded) ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 19:05:57 -05:00
yindo closed this issue 2026-02-21 19:05:57 -05:00
Author
Owner

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

How can I resolve this? It works fine when I call it locally using Python code.

The error log from dify is as follows:
2025-03-26 01:45:24,815.815 ERROR [Dummy-1231644] [models.py:159] - save model credentials error: Credentials validation failed with status code 403 Traceback (most recent call last): File "/app/api/controllers/console/workspace/models.py", line 151, in post model_provider_service.save_model_credentials( File "/app/api/services/model_provider_service.py", line 250, in save_model_credentials provider_configuration.add_or_update_custom_model_credentials( File "/app/api/core/entities/provider_configuration.py", line 390, in add_or_update_custom_model_credentials provider_model_record, credentials = self.custom_model_credentials_validate(model_type, model, credentials) File "/app/api/core/entities/provider_configuration.py", line 370, in custom_model_credentials_validate credentials = model_provider_factory.model_credentials_validate( File "/app/api/core/model_runtime/model_providers/model_provider_factory.py", line 123, in model_credentials_validate model_instance.validate_credentials(model, filtered_credentials) File "/app/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py", line 144, in validate_credentials raise CredentialsValidateFailedError( core.model_runtime.errors.validate.CredentialsValidateFailedError: Credentials validation failed with status code 403

@Tingfing6 commented on GitHub (Mar 25, 2025): How can I resolve this? It works fine when I call it locally using Python code. The error log from dify is as follows: 2025-03-26 01:45:24,815.815 ERROR [Dummy-1231644] [models.py:159] - save model credentials error: Credentials validation failed with status code 403 Traceback (most recent call last): File "/app/api/controllers/console/workspace/models.py", line 151, in post model_provider_service.save_model_credentials( File "/app/api/services/model_provider_service.py", line 250, in save_model_credentials provider_configuration.add_or_update_custom_model_credentials( File "/app/api/core/entities/provider_configuration.py", line 390, in add_or_update_custom_model_credentials provider_model_record, credentials = self.custom_model_credentials_validate(model_type, model, credentials) File "/app/api/core/entities/provider_configuration.py", line 370, in custom_model_credentials_validate credentials = model_provider_factory.model_credentials_validate( File "/app/api/core/model_runtime/model_providers/model_provider_factory.py", line 123, in model_credentials_validate model_instance.validate_credentials(model, filtered_credentials) File "/app/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py", line 144, in validate_credentials raise CredentialsValidateFailedError( core.model_runtime.errors.validate.CredentialsValidateFailedError: Credentials validation failed with status code 403
Author
Owner

@dosubot[bot] commented on GitHub (Mar 25, 2025):

To resolve the "Credentials validation failed with status code 403" error when adding an OpenAI-API-compatible model, ensure the following:

  1. API Key and Endpoint: Double-check that the api_key and endpoint_url are correctly configured and authorized for the API request. Even if it works locally, the configuration in Dify might require additional parameters or a different setup [1].

  2. Proxy Settings: If you're using Docker, make sure that the containers spawned by Docker Compose do not inherit the HTTP proxy settings of the Docker host. This has been identified as a cause of similar issues [2].

  3. LAN Services: If you're using LM Studio, ensure that LAN services are turned on in the settings before using the OpenAI-API-compatible model [2].

  4. Environment Variables: You can add an environment variable in the docker-compose.yaml for the API and worker services:

    OPENAI_API_BASE: 'https://<your-openai-mirror-domain>/v1'
    

    This can help in cases where the API base URL needs to be explicitly set [3].

These steps should help resolve the authentication issue you're encountering.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 25, 2025): <!-- Answer --> To resolve the "Credentials validation failed with status code 403" error when adding an OpenAI-API-compatible model, ensure the following: 1. **API Key and Endpoint**: Double-check that the `api_key` and `endpoint_url` are correctly configured and authorized for the API request. Even if it works locally, the configuration in Dify might require additional parameters or a different setup <sup>[[1]](https://github.com/langgenius/dify/issues/13560)</sup>. 2. **Proxy Settings**: If you're using Docker, make sure that the containers spawned by Docker Compose do not inherit the HTTP proxy settings of the Docker host. This has been identified as a cause of similar issues <sup>[[2]](https://github.com/langgenius/dify/issues/14231)</sup>. 3. **LAN Services**: If you're using LM Studio, ensure that LAN services are turned on in the settings before using the OpenAI-API-compatible model <sup>[[2]](https://github.com/langgenius/dify/issues/14231)</sup>. 4. **Environment Variables**: You can add an environment variable in the `docker-compose.yaml` for the API and worker services: ```yaml OPENAI_API_BASE: 'https://<your-openai-mirror-domain>/v1' ``` This can help in cases where the API base URL needs to be explicitly set <sup>[[3]](https://github.com/langgenius/dify/issues/60)</sup>. These steps should help resolve the authentication issue you're encountering. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/cb92381d-4e43-43e7-95eb-a14601f09304?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/cb92381d-4e43-43e7-95eb-a14601f09304?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/cb92381d-4e43-43e7-95eb-a14601f09304?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/cb92381d-4e43-43e7-95eb-a14601f09304?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/cb92381d-4e43-43e7-95eb-a14601f09304?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/cb92381d-4e43-43e7-95eb-a14601f09304?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/cb92381d-4e43-43e7-95eb-a14601f09304?feedback_type=other)</sup>
Author
Owner

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

dify\docker\ssrf_proxy目录下
修改配置文件.squid.conf.template
找到这两个配置,然后注销掉
http_access allow Safe_ports
http_access allow CONNECT SSL_ports

#http_access deny !Safe_ports
#http_access deny CONNECT !SSL_ports
重启搞定,应该就可以搞定了

@SuJack commented on GitHub (Apr 8, 2025): dify\docker\ssrf_proxy目录下 修改配置文件.squid.conf.template 找到这两个配置,然后注销掉 http_access allow Safe_ports http_access allow CONNECT SSL_ports #http_access deny !Safe_ports #http_access deny CONNECT !SSL_ports 重启搞定,应该就可以搞定了
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12135