fix(auth): apply API key model mapping to request model

This commit is contained in:
hkfires
2026-01-15 12:34:05 +08:00
parent bcd4d9595f
commit 8bc6df329f

View File

@@ -593,6 +593,7 @@ func (m *Manager) executeMixedOnce(ctx context.Context, providers []string, req
execReq := req execReq := req
execReq.Model = rewriteModelForAuth(routeModel, auth) execReq.Model = rewriteModelForAuth(routeModel, auth)
execReq.Model = m.applyOAuthModelMapping(auth, execReq.Model) execReq.Model = m.applyOAuthModelMapping(auth, execReq.Model)
execReq.Model = m.applyAPIKeyModelMapping(auth, execReq.Model)
resp, errExec := executor.Execute(execCtx, auth, execReq, opts) resp, errExec := executor.Execute(execCtx, auth, execReq, opts)
result := Result{AuthID: auth.ID, Provider: provider, Model: routeModel, Success: errExec == nil} result := Result{AuthID: auth.ID, Provider: provider, Model: routeModel, Success: errExec == nil}
if errExec != nil { if errExec != nil {
@@ -641,6 +642,7 @@ func (m *Manager) executeCountMixedOnce(ctx context.Context, providers []string,
execReq := req execReq := req
execReq.Model = rewriteModelForAuth(routeModel, auth) execReq.Model = rewriteModelForAuth(routeModel, auth)
execReq.Model = m.applyOAuthModelMapping(auth, execReq.Model) execReq.Model = m.applyOAuthModelMapping(auth, execReq.Model)
execReq.Model = m.applyAPIKeyModelMapping(auth, execReq.Model)
resp, errExec := executor.CountTokens(execCtx, auth, execReq, opts) resp, errExec := executor.CountTokens(execCtx, auth, execReq, opts)
result := Result{AuthID: auth.ID, Provider: provider, Model: routeModel, Success: errExec == nil} result := Result{AuthID: auth.ID, Provider: provider, Model: routeModel, Success: errExec == nil}
if errExec != nil { if errExec != nil {
@@ -689,6 +691,7 @@ func (m *Manager) executeStreamMixedOnce(ctx context.Context, providers []string
execReq := req execReq := req
execReq.Model = rewriteModelForAuth(routeModel, auth) execReq.Model = rewriteModelForAuth(routeModel, auth)
execReq.Model = m.applyOAuthModelMapping(auth, execReq.Model) execReq.Model = m.applyOAuthModelMapping(auth, execReq.Model)
execReq.Model = m.applyAPIKeyModelMapping(auth, execReq.Model)
chunks, errStream := executor.ExecuteStream(execCtx, auth, execReq, opts) chunks, errStream := executor.ExecuteStream(execCtx, auth, execReq, opts)
if errStream != nil { if errStream != nil {
rerr := &Error{Message: errStream.Error()} rerr := &Error{Message: errStream.Error()}