ChatGPTNextWeb / ChatGPTNextWeb/NextChat
[Bug] Invalid Token Error in NextChat+One-API Local Deployment When Using SiliconFlow Model
- Dominant language
- TypeScript
- Stars
- 88.8k
- Forks
- 59.1k
- PR merge metrics
- No merged PRs in 30d
Description
### π¦ Deployment Method
Docker
### π Version
2.16.0
### π» Operating System
Other Linux
### π System Version
1panel Docker
### π Browser
Chrome
### π Browser Version
Latest
### π Bug Description
When deploying NextChat with One-API locally, an "Invalid token" error occurs when attempting to use the SiliconFlow model. The issue arises because NextChat does not correctly route requests through One-API's gateway, instead attempting to directly call SiliconFlow's API without using the One-API Token. Other UI applications (e.g., Chatbox) work correctly with the same setup.
### π· Recurrence Steps
1. Deploy NextChat and One-API locally.
2. Add SiliconFlow's API key and other channels (e.g., Alibaba's Tongyi Qianwen) in One-API.
3. Configure NextChat's environment variables with the One-API token as follows:
```yaml
environment:
- OPENAI_API_KEY=sk-dUJhlhHAabdVXsqN22B205Bxxxxxxxxxxxxx6e65B1Ad
- CODE=xxxxx
- BASE_URL=http://154.xxx.241.166:3000
- CUSTOM_MODELS=-all,+deepseek-ai/DeepSeek-R1,+Pro/deepseek-ai/DeepSeek-R1,+deepseek-ai/DeepSeek-V3,+Pro/deepseek-ai/DeepSeek-V3,+deepseek-r1,+deepseek-v3,+qwen-max-latest,+deepseek-r1-250120,+deepseek-v3-241226
- DEFAULT_MODEL=deepseek-ai/DeepSeek-V3
```
4. Attempt to use the SiliconFlow model in NextChat.
### π¦ Expected Behavior
**Expected Behavior:**
NextChat should route requests through One-API's gateway and successfully connect to the SiliconFlow model using the One-API Token.
**Actual Behavior:**
An "Invalid token" error occurs. The logs indicate that NextChat is attempting to directly call SiliconFlow's API without using the One-API Token.
### π Additional Information
**Logs:**
```
1Panel-chatgpt-next-web-Z6DO | [Server Config] using 1 of 1 api key - sk-dUJhlhHAabdVXsqN22B2eeeeeeeeeeeaAd1e55B46e65B1Ad
1Panel-chatgpt-next-web-Z6DO | [siliconflow Route] params { provider: 'siliconflow', path: [ 'v1', 'chat', 'completions' ] }
1Panel-chatgpt-next-web-Z6DO | [SiliconFlow Route] params { provider: 'siliconflow', path: [ 'v1', 'chat', 'completions' ] }
1Panel-chatgpt-next-web-Z6DO | [Server Config] using 1 of 1 api key - sk-dUJhlhHAabdVXsqN22B2eeeeeeeeeeeaAd1e55B46e65B1Ad
1Panel-chatgpt-next-web-Z6DO | [Auth] allowed hashed codes: [ '4f7487bda8deeeeeeeeeee7e3633ff38a7d' ]
1Panel-chatgpt-next-web-Z6DO | [Auth] got access code: xxxxxxxx
1Panel-chatgpt-next-web-Z6DO | [Auth] hashed access code: 4f7487bda8deeeeeeeeeee7e3633ff38a7d
1Panel-chatgpt-next-web-Z6DO | [User IP] 172.70.**.68
1Panel-chatgpt-next-web-Z6DO | [Time] 2/23/2025, 1:04:23 PM
1Panel-chatgpt-next-web-Z6DO | [Server Config] using 1 of 1 api key - sk-dUJhlhHAabdVXsqN22B2eeeeeeeeeeeaAd1e55B46e65B1Ad
1Panel-chatgpt-next-web-Z6DO | [Auth] admin did not provide an api key
1Panel-chatgpt-next-web-Z6DO | [Proxy] /v1/chat/completions
1Panel-chatgpt-next-web-Z6DO | [Base Url] https://api.siliconflow.cn
1Panel-chatgpt-next-web-Z6DO | [Server Config] using 1 of 1 api key - sk-dUJhlhHAabdVXsqN22B2eeeeeeeeeeeaAd1e55B46e65B1Ad
```
**Root Cause:**
NextChat does not correctly route requests through One-API's gateway, instead attempting to directly call SiliconFlow's API without using the One-API Token.
**Proposed Solution:**
1.Verify that BASE_URL in NextChat's configuration correctly points to One-API's address.
2.Ensure that NextChat's code logic routes all requests through One-API's gateway.
3.Add detailed logging to debug the request routing process.
**Additional Information:**
-Other UI applications (e.g., Chatbox) work correctly with the same setup.
-The issue is specific to NextChat when using the SiliconFlow model.
---
Let me know if you need further adjustments!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.