Moge-Row commited on
Commit
a3b4fd8
·
1 Parent(s): 7b9261c

fix anthropic RWPX

Browse files
Files changed (1) hide show
  1. internal/handler/anthropic.go +6 -2
internal/handler/anthropic.go CHANGED
@@ -28,8 +28,12 @@ func HandleMessages(w http.ResponseWriter, r *http.Request) {
28
  writeAnthropicError(w, http.StatusUnauthorized, "authentication_error", "Missing API key")
29
  return
30
  }
31
-
32
- if token == "free" {
 
 
 
 
33
  anonymousToken, err := auth.GetAnonymousToken()
34
  if err != nil {
35
  logger.LogError("Failed to get anonymous token: %v", err)
 
28
  writeAnthropicError(w, http.StatusUnauthorized, "authentication_error", "Missing API key")
29
  return
30
  }
31
+ ok, reason := CheckAndTrack(token, 0)
32
+ if !ok {
33
+ writeAnthropicError(w, http.StatusTooManyRequests, "rate_limit_error", reason)
34
+ return
35
+ }
36
+ if token == "free" || strings.HasPrefix(token, "RWPX-") {
37
  anonymousToken, err := auth.GetAnonymousToken()
38
  if err != nil {
39
  logger.LogError("Failed to get anonymous token: %v", err)