ChatGPTNextWeb / ChatGPTNextWeb/NextChat

[Bug] Invalid Token Error in NextChat+One-API Local Deployment When Using SiliconFlow Model

Open
#6,286 0 comments 0 reactions 0 assignees View on GitHub
bug
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.