Dify Version 0.6.16 fails to pass the API verification when calling the Xinference model. #5018

Closed
opened 2026-02-21 18:09:01 -05:00 by yindo · 7 comments
Owner

Originally created by @lonnys on GitHub (Aug 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

Version 0.6.16

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Step1. Create Xinference API verification file:userauth.json
{ "auth_config": { "algorithm": "HS256", "secret_key": "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7", "token_expire_in_minutes": 30 }, "user_config": [ { "username": "user1", "password": "secret1", "permissions": [ "admin" ], "api_keys": [ "sk-72tkvudyGLPMi", "sk-ZOTLIY4gt9w11" ] }, { "username": "user2", "password": "secret2", "permissions": [ "models:list", "models:read" ], "api_keys": [ "sk-35tkasdyGLYMy", "sk-ALTbgl6ut981w" ] } ] }
Step2. Launch Xinference:xinference-local -H 0.0.0.0 -p 9997 --auth-config userauth.json
Step3. Configure Dify
image

Other instructions: Xinference is running normally

image

✔️ Expected Behavior

Dify supports the verification of Xinference API key

Actual Behavior

Dify failed to pass the verification and prompted the following error

Failed to get the model description, detail: Not authenticated

Originally created by @lonnys on GitHub (Aug 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 Version 0.6.16 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Step1. Create Xinference API verification file:userauth.json `{ "auth_config": { "algorithm": "HS256", "secret_key": "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7", "token_expire_in_minutes": 30 }, "user_config": [ { "username": "user1", "password": "secret1", "permissions": [ "admin" ], "api_keys": [ "sk-72tkvudyGLPMi", "sk-ZOTLIY4gt9w11" ] }, { "username": "user2", "password": "secret2", "permissions": [ "models:list", "models:read" ], "api_keys": [ "sk-35tkasdyGLYMy", "sk-ALTbgl6ut981w" ] } ] }` Step2. Launch Xinference:xinference-local -H 0.0.0.0 -p 9997 --auth-config userauth.json Step3. Configure Dify <img width="1087" alt="image" src="https://github.com/user-attachments/assets/99e074ed-a0ec-4036-9159-27e3f069e2b8"> Other instructions: Xinference is running normally <img width="1422" alt="image" src="https://github.com/user-attachments/assets/4b180526-4f08-4d17-b6c5-0900a7c9121d"> ### ✔️ Expected Behavior Dify supports the verification of Xinference API key ### ❌ Actual Behavior Dify failed to pass the verification and prompted the following error Failed to get the model description, detail: Not authenticated
yindo added the 🐞 bug label 2026-02-21 18:09:01 -05:00
yindo closed this issue 2026-02-21 18:09:01 -05:00
Author
Owner

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

Hey @lonnys! I'm here to help you with any bugs, questions, or contributions you might have for the Dify repository. Let's get this issue sorted out together!

To resolve the authentication issue with Dify and successfully verify the Xinference API key, follow these steps:

  1. Ensure Correct Configuration in userauth.json:
    Make sure your userauth.json file is correctly configured with the necessary authentication details. Here is an example configuration:

    {
        "auth_config": {
            "algorithm": "HS256",
            "secret_key": "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7",
            "token_expire_in_minutes": 30
        },
        "user_config": [
            {
                "username": "user1",
                "password": "secret1",
                "permissions": [
                    "admin"
                ],
                "api_keys": [
                    "sk-72tkvudyGLPMi",
                    "sk-ZOTLIY4gt9w11"
                ]
            },
            {
                "username": "user2",
                "password": "secret2",
                "permissions": [
                    "models:list",
                    "models:read"
                ],
                "api_keys": [
                    "sk-35tkasdyGLYMy",
                    "sk-ALTbgl6ut981w"
                ]
            }
        ]
    }
    
  2. Launch Xinference with Authentication:
    Start Xinference with the correct host configuration and authentication file:

    xinference-local -H 0.0.0.0 -p 9997 --auth-config userauth.json
    
  3. Configure Dify with Correct Details:
    In Dify, go to Settings > Model Providers > Xinference and enter the following details:

    • Model name: bge-reranker (or your specific model name)
    • Server URL: http://<Machine_IP>:9997 (Replace <Machine_IP> with your host machine's IP address)
    • Model UID: your_model_uid (Replace with your actual model UID)
    • API key: sk-72tkvudyGLPMi (or the relevant API key from your userauth.json)
  4. Verify API Key and Authentication:
    Ensure that the API key you are using in Dify matches one of the API keys listed in the userauth.json file for the corresponding user. The API key should be included in the request headers as follows:

    Authorization: Bearer sk-72tkvudyGLPMi
    
  5. Check for Network Accessibility:
    Ensure that the Dify container can access the Xinference endpoint. If using Docker, the Dify container cannot access localhost inside the container, so you need to use the host IP address.

By following these steps, you should be able to resolve the authentication issue and successfully verify the Xinference API key in Dify [1][2].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Aug 13, 2024): <!-- Greeting --> Hey @lonnys! I'm here to help you with any bugs, questions, or contributions you might have for the Dify repository. Let's get this issue sorted out together! <!-- Answer --> To resolve the authentication issue with Dify and successfully verify the Xinference API key, follow these steps: 1. **Ensure Correct Configuration in `userauth.json`:** Make sure your `userauth.json` file is correctly configured with the necessary authentication details. Here is an example configuration: ```json { "auth_config": { "algorithm": "HS256", "secret_key": "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7", "token_expire_in_minutes": 30 }, "user_config": [ { "username": "user1", "password": "secret1", "permissions": [ "admin" ], "api_keys": [ "sk-72tkvudyGLPMi", "sk-ZOTLIY4gt9w11" ] }, { "username": "user2", "password": "secret2", "permissions": [ "models:list", "models:read" ], "api_keys": [ "sk-35tkasdyGLYMy", "sk-ALTbgl6ut981w" ] } ] } ``` 2. **Launch Xinference with Authentication:** Start Xinference with the correct host configuration and authentication file: ```bash xinference-local -H 0.0.0.0 -p 9997 --auth-config userauth.json ``` 3. **Configure Dify with Correct Details:** In Dify, go to `Settings > Model Providers > Xinference` and enter the following details: - **Model name**: `bge-reranker` (or your specific model name) - **Server URL**: `http://<Machine_IP>:9997` (Replace `<Machine_IP>` with your host machine's IP address) - **Model UID**: `your_model_uid` (Replace with your actual model UID) - **API key**: `sk-72tkvudyGLPMi` (or the relevant API key from your `userauth.json`) 4. **Verify API Key and Authentication:** Ensure that the API key you are using in Dify matches one of the API keys listed in the `userauth.json` file for the corresponding user. The API key should be included in the request headers as follows: ```http Authorization: Bearer sk-72tkvudyGLPMi ``` 5. **Check for Network Accessibility:** Ensure that the Dify container can access the Xinference endpoint. If using Docker, the Dify container cannot access `localhost` inside the container, so you need to use the host IP address. By following these steps, you should be able to resolve the authentication issue and successfully verify the Xinference API key in Dify <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/xinference/xinference.yaml)</sup><sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/en/guides/model-configuration/xinference.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@lonnys commented on GitHub (Aug 13, 2024):

  1. Yes, I configured and ran it according to this step.
  2. But in the end, the API KEY still couldn't be verified.
  3. And the API Key of xinference is working normally. The following are the test results.

curl -H"Authorization: Bearer sk-72tkvudyGLPMi" http://10.8.148.133:9997/v1/models OUTPUT: {"object":"list","data":[{"id":"bge-reranker","object":"model","created":0,"owned_by":"xinference","model_type":"rerank","address":"0.0.0.0:61848","accelerators":[],"type":"normal","model_name":"bge-reranker","language":["en","zh"],"model_revision":null,"replica":1}]}%

4. In addition, if the API KEY is not verified, the Dify container can access the Xinference endpoint

@lonnys commented on GitHub (Aug 13, 2024): 1. **Yes, I configured and ran it according to this step.** 2. **But in the end, the API KEY still couldn't be verified.** 3. **And the API Key of xinference is working normally. The following are the test results.** ``` curl -H"Authorization: Bearer sk-72tkvudyGLPMi" http://10.8.148.133:9997/v1/models OUTPUT: {"object":"list","data":[{"id":"bge-reranker","object":"model","created":0,"owned_by":"xinference","model_type":"rerank","address":"0.0.0.0:61848","accelerators":[],"type":"normal","model_name":"bge-reranker","language":["en","zh"],"model_revision":null,"replica":1}]}%``` **4. In addition, if the API KEY is not verified, the Dify container can access the Xinference endpoint**
Author
Owner

@lonnys commented on GitHub (Aug 14, 2024):

hello! Can anyone help me?

@lonnys commented on GitHub (Aug 14, 2024): hello! Can anyone help me?
Author
Owner

@realethanhsu commented on GitHub (Aug 17, 2024):

I have fixed this issue. Please refer to #7369 for details.

This PR is currently open. You can temporarily disable Xinference's authentication by running the following command: xinference-local -H 0.0.0.0 -p 9997, don't append --auth-config at the end.

@realethanhsu commented on GitHub (Aug 17, 2024): I have fixed this issue. Please refer to #7369 for details. This PR is currently open. You can temporarily disable Xinference's authentication by running the following command: `xinference-local -H 0.0.0.0 -p 9997`, don't append `--auth-config` at the end.
Author
Owner

@lonnys commented on GitHub (Aug 19, 2024):

Great! Looking forward to the release of the next version!

@lonnys commented on GitHub (Aug 19, 2024): Great! Looking forward to the release of the next version!
Author
Owner

@realethanhsu commented on GitHub (Aug 19, 2024):

Great! Looking forward to the release of the next version!

Yes, 0.7.1 was released just now!
Hope you enjoy it!

@realethanhsu commented on GitHub (Aug 19, 2024): > Great! Looking forward to the release of the next version! Yes, 0.7.1 was released just now! Hope you enjoy it!
Author
Owner

@crazywoola commented on GitHub (Aug 19, 2024):

Fixed in 0.7.1

@crazywoola commented on GitHub (Aug 19, 2024): Fixed in 0.7.1
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5018