MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / unifiedModelsHandler

Method unifiedModelsHandler

internal/api/server.go:995–1018  ·  view source on GitHub ↗

unifiedModelsHandler creates a unified handler for the /v1/models endpoint that routes to different handlers based on the request. Anthropic API requests (Anthropic-Version header, or a claude-cli User-Agent) route to the Claude handler, otherwise they route to the OpenAI handler.

(openaiHandler *openai.OpenAIAPIHandler, claudeHandler *claude.ClaudeCodeAPIHandler)

Source from the content-addressed store, hash-verified

993// Anthropic API requests (Anthropic-Version header, or a claude-cli User-Agent)
994// route to the Claude handler, otherwise they route to the OpenAI handler.
995func (s *Server) unifiedModelsHandler(openaiHandler *openai.OpenAIAPIHandler, claudeHandler *claude.ClaudeCodeAPIHandler) gin.HandlerFunc {
996 return func(c *gin.Context) {
997 if _, ok := c.Request.URL.Query()["client_version"]; ok {
998 if s != nil && s.cfg != nil && s.cfg.Home.Enabled {
999 s.handleHomeCodexClientModels(c)
1000 return
1001 }
1002 openaiHandler.OpenAIModels(c)
1003 return
1004 }
1005
1006 if s != nil && s.cfg != nil && s.cfg.Home.Enabled {
1007 s.handleHomeModels(c)
1008 return
1009 }
1010
1011 // Route to Claude handler for Anthropic API requests.
1012 if isAnthropicModelsRequest(c) {
1013 claudeHandler.ClaudeModels(c)
1014 } else {
1015 openaiHandler.OpenAIModels(c)
1016 }
1017 }
1018}
1019
1020func (s *Server) handleHomeCodexClientModels(c *gin.Context) {
1021 entries, ok := s.loadHomeModelEntries(c)

Callers 1

setupRoutesMethod · 0.95

Calls 6

handleHomeModelsMethod · 0.95
isAnthropicModelsRequestFunction · 0.85
QueryMethod · 0.80
OpenAIModelsMethod · 0.80
ClaudeModelsMethod · 0.80

Tested by

no test coverage detected