Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PORT=8000
# API 配置
# ===================
# API 端点地址
API_ENDPOINT=https://chat.z.ai/api/chat/completions
API_ENDPOINT=https://chat.z.ai/api/v2/chat/completions

# 认证令牌(支持多个,逗号分隔)
# 用于验证客户端请求
Expand Down
6 changes: 3 additions & 3 deletions internal/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ func makeUpstreamRequest(token string, messages []Message, model string, imageUR

signature := GenerateSignature(userID, requestID, latestUserContent, timestamp)

url := fmt.Sprintf("https://chat.z.ai/api/v2/chat/completions?timestamp=%d&requestId=%s&user_id=%s&version=0.0.1&platform=web&token=%s&current_url=%s&pathname=%s&signature_timestamp=%d",
timestamp, requestID, userID, token,
url := fmt.Sprintf("%s?timestamp=%d&requestId=%s&user_id=%s&version=0.0.1&platform=web&token=%s&current_url=%s&pathname=%s&signature_timestamp=%d",
Cfg.APIEndpoint, timestamp, requestID, userID, token,
fmt.Sprintf("https://chat.z.ai/c/%s", chatID),
fmt.Sprintf("/c/%s", chatID),
timestamp)
Expand Down Expand Up @@ -288,7 +288,7 @@ func makeUpstreamRequest(token string, messages []Message, model string, imageUR

LogDebug("Upstream request: model=%s, messages=%d, XFF=%s", targetModel, len(messages), randomIP)

client := &http.Client{Timeout: 60 * time.Second}
client := &http.Client{Timeout: 300 * time.Second}
resp, err := client.Do(req)
if err != nil {
return nil, "", err
Expand Down
2 changes: 1 addition & 1 deletion internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func LoadConfig() {
Port: getEnvString("PORT", "8000"),

// API Configuration
APIEndpoint: getEnvString("API_ENDPOINT", "https://chat.z.ai/api/chat/completions"),
APIEndpoint: getEnvString("API_ENDPOINT", "https://chat.z.ai/api/v2/chat/completions"),
AuthTokens: getEnvStringSlice("AUTH_TOKEN"),
BackupTokens: getEnvStringSlice("BACKUP_TOKEN"),

Expand Down
10 changes: 5 additions & 5 deletions internal/model_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ func initBuiltinMappings() {
DisplayName: "GLM-5",
UpstreamModelID: "glm-5",
UpstreamModelName: "GLM-5",
EnableThinking: true,
AutoWebSearch: true,
MCPServers: []string{"advanced-search"},
EnableThinking: false,
AutoWebSearch: false,
MCPServers: []string{},
OwnedBy: "z.ai",
IsBuiltin: true,
}
Expand All @@ -175,8 +175,8 @@ func initBuiltinMappings() {
UpstreamModelID: "glm-5",
UpstreamModelName: "GLM-5-Thinking",
EnableThinking: true,
AutoWebSearch: true,
MCPServers: []string{"advanced-search"},
AutoWebSearch: false,
MCPServers: []string{},
OwnedBy: "z.ai",
IsBuiltin: true,
}
Expand Down