Add telemetry
This commit is contained in:
@@ -51,6 +51,15 @@ func (u *UpstreamClient) applyHeaders(req *http.Request, token string, streaming
|
||||
req.Header.Del("x-api-key")
|
||||
if strings.HasPrefix(token, "sk-ant-oat") {
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
// OAuth tokens require this beta flag — without it the API rejects with 401
|
||||
existing := req.Header.Get("anthropic-beta")
|
||||
if !strings.Contains(existing, "oauth-2025-04-20") {
|
||||
if existing == "" {
|
||||
req.Header.Set("anthropic-beta", "oauth-2025-04-20")
|
||||
} else {
|
||||
req.Header.Set("anthropic-beta", existing+",oauth-2025-04-20")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
req.Header.Set("x-api-key", token)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user